function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
raviteja p 21raviteja p 21 

system.debug can work in batch apex

Bhargavi TunuguntlaBhargavi Tunuguntla
Hi Raviteja

Yes we can write debug statements in batch apex. Those will be displayed when you run the batch class in 'Batch Apex' debug log.

Thanks.
 
Jolly_BirdiJolly_Birdi
Hello @raviteja

Yes System.debug can work in Apex class. 

For checking its results you can refer Logs from Developer console or from Debug Logs Under setup.

Thanks,
Jolly Birdi

Please mark it as best answer if you find it positive.
raviteja p 21raviteja p 21
But sometimes it's working and sometimes not working why
Bhargavi TunuguntlaBhargavi Tunuguntla
That should always .I think you need to set the debug logs for your user.Try renewing the debug logs and test it.This should work.

or 

There may be issue reaching the maximun debug limit in your org .Clear some of the debug logs and check.
Ajay K DubediAjay K Dubedi
Hi raviteja,

I understand your query. To check system.debug you need to check your debug logs and there you should find it.
For Batch class as we know there are methods-Start, execute and finish.
If in case a method in the batch fails to execute you will not be able to view debugs of that method as well as debugs of the methods to be executed after 
that.

Hope you got this explanation. Please mark it as best answer if you find it helpful.

Thanks.
Ajay Dubedi