50

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 resolves 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.

  • 3
    By the by, skipping 50+ megabytes to log is fairly significant. It would be nice to have some clues about what was being skipped. Maybe a summary of the most skipped event type. – Daniel Ballinger Jun 27 '16 at 22:30
  • So... the truncation is broken, I suppose is what you're going to tell me? – sfdcfox Jun 28 '16 at 0:04
  • @sfdcfox I'm not sure if it is broken or not. The best I can say is that it its behavior is undefined. It is definitely there and doing stuff. What stuff it should be doing and when, I'm not so clear on. – Daniel Ballinger Jun 28 '16 at 0:10
  • 6
    Not only is it not defined, it's broken in undocumented ways. I really had fun trying to find an answer, but really I just ended up with more questions. For example, guess what System.debug('*'.repeat(2300000)); does...? – sfdcfox Jun 28 '16 at 0:41
  • 1
    To remove confusion: "I executed this ExeAnon and got no returned system.debug (Total Log was 2MB)..." – NZ Dev Jan 31 '17 at 8:45
0

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.

  • The behavior you are describing sounds like the MAXIMUM DEBUG LOG SIZE REACHED style truncation. Apex gets to the maximum log size and then just stops logging. The Skipped X bytes of detailed log is different. It occurs at different locations within the log and doesn't appear to be deterministic (at least last time I checked). – Daniel Ballinger Jun 5 '18 at 0:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.