How does Salesforce determine where to apply the “*** Skipped X bytes of detailed log” section in a log

Firstly, this question isn’t about how to access missing log content when a *** Skipped 53353122 bytes of detailed log style message is encountered. That is covered in another question and revolves around altering log levels.

I’d like to know when and how Salesforce applies this log content skipping functionality.

  • What determines its location in the log?
  • What log messages get kept and which get skipped over?

Anecdotally it seems to appear around the middle of the log for me, which always makes me think I’m missing a significant portion from the middle of the log file.

I did find the following in the Debug Log docs:

Each debug log must be 2 MB or smaller. Debug logs that are larger than 2 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.

It still seems a bit arbitrary about what will be removed once you reach the log file size limit. Why cull one log message over another? Why not just run until the MAXIMUM DEBUG LOG SIZE REACHED message and then stop logging?

In a discussion with Chris Peterson he indicated that in more recent API versions (post v24.0?) that lower severity events are evicted first. Some basic testing based on @sfdcfox’s comments using large log messages can (kind of) show this.

Try changing the LoggingLevel on each debug statement. With no levels defined the d‘s got logged and everything else skipped. As it is below the b‘s get logged and everything else skipped. Where did the a‘s go? (Info > Debug > Fine)

System.debug(LoggingLevel.Info, 'a'.repeat(1500000));
System.debug(LoggingLevel.Debug, 'b'.repeat(1500000));
System.debug(LoggingLevel.Fine, 'c'.repeat(1500000));
System.debug(LoggingLevel.Finest, 'd'.repeat(1500000));

Update: It appears to be nondeterministic. Running the same anonymous Apex with the same logging levels results in differing log output. Sometimes only the b‘s messages appear along with a skipped message. Sometimes the a‘s appear. Sometimes I get a MAXIMUM DEBUG LOG SIZE REACHED.


Salesforce basically takes the first 2MB of your debug log text and prints it. Anything past that 2MB cutoff is not output on the logs, but the size of the text if it were to show up is what is shown in the “Skipped * bytes”. What is shown in the Debug Logs is specified based on your Debug Profile Debug Levels for each Debug Type. As a best practice, if debugging Apex code, I always put:

System.debug(LoggingLevel.ERROR, '<debug message>');

Then set the debug level to ERROR for Apex Code. That way it filters out a lot of the junk that Apex will put in your logs by default. Make sure to turn off any types that you aren’t interested in as well. Salesforce is working on improving debugging (added a new trace feature), but definitely need to increase this log size as they often put a lot of junk that is hard to get rid of and eats up all the debug log space.

Source : Link , Question Author : Daniel Ballinger , Answer Author : Cody Cusic

Leave a Comment