I've got a number of old apex classes that I am planning up updating to use a more recent version of the Salesforce.com API. Of course, it would be better still if I could retire some of these classes. I know they haven't been updated in years. Is there a way to determine when the class was last run? I don't see anything like a "Last run" property when I edit one of the Apex class views. Is this information available anywhere else (like maybe Eclipse)?

edited to add The metadata API does not even have "date last modified" for an Apex class. "Date last run" was too much to hope for.

2 Answers 2


There is no log maintained by Salesforce around apex execution by default. If you wanted to find out this information in the future I would suggest building something in your system which tracks such information. Which should be quite straight forward. Here are the steps.

  1. Create a custom object to log this information, it could have fields such as : apex class name, running user etc.

  2. Create a utility class / method which makes an entry into this custom object : //Sudo code Public static LogClassExecute(string ClassName, string UserID) { customobject_c newEntry = new customobject_c; newEntry.className = ClassName; // and so on... }

  3. In all the classes you want to log ... Include the call to utility class as the first line in the constructor. (About this point, there is a better way to do this ... Which is use an abstract class design pattern. Which all the apex classes inherit from)

  • I was hoping I would not have to change the code to find out if it was in use, but I do have a logging utility class I can adapt for this purpose.
    – Jagular
    Commented Sep 23, 2014 at 16:47

I see that this is an old post from 2014. Now we can use EventLogFile object. You could filter on Event Types to retrieve Log Files for Apex executions. We cannot view the EventLogFile on the UI. Have to use Workbench or Heroku App to view and download the files. The below trailhead gives you details on the options to download files https://trailhead.salesforce.com/content/learn/modules/event_monitoring/event_monitoring_download

  • 2
    Note that this feature is a paid add on.
    – Adrian Larson
    Commented Dec 8, 2020 at 19:03
  • Yes yes. This is a paid feature. Thanks for the clarification. Commented Dec 8, 2020 at 19:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .