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
bvdbbvdb 

Best way to debug line by line through multiple triggers and classes

We're trying to debug some Apex triggers/classes but the log files end up being so long that our debug statements get cut off. If we set it to display less information in the log (Error, Warning, or Info), our debug statements don't show up.

 

Right now we're writing debug information to custom fields.

 

Is there any way to iterate line by line through the code to identify where the problem lies?

 

Thanks!

Jeremy.NottinghJeremy.Nottingh

One thing I've done before in these situations is to keep a manual debug log running throughout the process and then email it to myself. E.g.

 

 

static testmethod void mytest()
{
   String debuglog = 'Debug started ' + system.now + '<br/>';
   


  //do logic here...
  debuglog += 'checkpoint reached. here are my values: ' + [variables to track] + '<br/>';

   Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
   mail.setToAddresses(new list<String> { 'myemailaddress@example.com' } );
   mail.sethtmlbody(debuglog);
   mail.setSubject('Debuglog');
   Messaging.sendemail(new list<SingleEmailMessage> { mail });

}

See if that will work for you.

Jeremy

bvdbbvdb

Thanks Jeremy, will try that! :)

David81David81

You can also change the log level of your debug statements if you'd like to cut down on some of the "clutter".

 

 

System.debug(Logginglevel.INFO, 'MsgTxt');

 

Valid log levels are (listed from lowest to highest):

  • ERROR
  • WARN
  • INFO
  • DEBUG
  • FINE
  • FINER
  • FINEST