I am trying to set a scheduled Apex job to run daily at 1AM. Records are not being inserted as I believe they should be. I imagine there is are errors occurring during execution of the class. I have a bunch of System.Debug statements to write errors that occur. I unfortunately do not see any debug logs listed on Setup -> Monitoring -> Debug Logs. All I see is User Trace Flags and an empty list under Debug Logs.
Debug logs are not running all the time, there is a limit of 20 logs captured per trace set up.
- Schedule the trace to start right before your batch scheduled time
- If the user is active in the system however this could consume the 20 logs before the batch is run
If your batch has a lot of 'chunks' you could consume the 20 logs before the error has occurred.
You best bet is to manually run the batch and monitor it via the dev console.
This solved it for me,
After scheduling your apex class either by using
dev console and
execute anonymous, or by using the UI,
- Go to
setup -> scheduledjobs and check the
Submitted bythe field for the specific scheduled job, this user name is important
- Go to
setup -> debug logsand click on
trace entity typemust be user
trace entity namemust be the same user as you saw in the
- Get your start and end time correct (make sure they overlap the time when your scheduled class will run)
- Select your
debug levelby referring to the official documentation in the Trailblazer Community or complete this Trailhead module