Monday, February 11, 2019

What happened to my Salesforce System.Debug statements?


On our project we have complex report generation which creates a debug log file at the 5MB limit when the Apex Debug Log Level is set to finest.  According to Salesforce:

“Each debug log must be 5 MB or smaller. Debug logs that are larger than 5 MB are reduced in size by removing older log lines, such as log lines for earlier System.debug statements. The log lines can be removed from any location, not just the start of the debug log.“


If you just want to see the debug statements, simply log at the error level and then set everything else to none.

    System.debug(LoggingLevel.ERROR, ‘some logging message’);

Debug Levels
  • Database : None
  • Workflow : None
  • Validation : None
  • Callouts : None
  • Apex Code : Error
  • Apex Profiling : None
  • Visualforce : None
  • System:  None
  • Wave: None
  • Nba: None

If you want to debug in Visual Studio at the Apex finest level, break your code up into small testable pieces so that you can pinpoint errors and the log files can be under the 5MB limit.  The Single Responsibility should be your best friend when working in Salesforce.

No comments:

Post a Comment