1

I have been working with a few classes in the Developer Console and Execute Anonymous Window. All of these classes have various system.debug() calls through the code - the log entries are used for troubleshooting, reporting, etc. It is nice to filter the log for USER_DEBUG and see exactly what is occurring.

I am beginning the process of wrapping the classes into an Apex Job using the Schedulable Interface, e.g.

global class sched_test implements Schedulable {

This class with instantiate the main class and run its init method. My question is, where do all of the system.debug() entries end up? I would imagine Setup > Monitoring > Debug Logs, but I'm not too sure.

My apologies if this is a simple question.

Cheers!

2 Answers 2

3

They end up in up to two different places: the Developer Console and Debug Logs. If you enable logging for the user that scheduled the job (Setup > Monitoring > Debug Logs), it will appear here. Additionally, if the Developer Console is open and active (e.g. you've used it in the past ten minutes or so), and you've scheduled the job yourself, the log will also appear there. Note that logging in both places respect their relevant debug log settings, so that usually means System must be set to DEBUG or higher to see the debug statements with those logs.

1
  • Ok - thanks about what I was thinking. Thanks for confirming! Dec 29, 2015 at 21:31
2

In addition to @sfdcfox, you might want to think about logging to a persistent custom object because if there's an exception, and debug logs are not turned on for the running user (or you have exhausted the set of logs that SFDC records), then you've lost any diagnosability for a completed job.

There are many patterns for this, one you could look at is in Dan Appleman's Advanced Apex Book, now in its 3rd Edition so it is au courant.

You must log in to answer this question.

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