Andrea Azzola

Tips and Techniques for Lifestyle Design

Dealing with Salesforce Maximum Debug Log Size

Posted on [Permalink]

When working with Apex code which iterates a lot, you may need to deal with a truncated log, the error looks like this:

MAXIMUM DEBUG LOG SIZE REACHED

At time of writing, the maximum allowed sized for a debug log is 2 megabytes.

The default monitoring level for Apex code in fact include a lot of clutter that most of the time you won't need (like METHOD_ENTRY, METHOD_EXIT), and by common practice, you should put a log filter on the monitored user, or the classes involved in the transaction by putting and override flag on them.

Unluckily, at time of writing, the platform does not allow fine-tuning of log levels. Whilst the first is specific to your monitoring sessions, the second will affect every process or user. My advice is to remove any class level filter override after use.

One approach I find particularly useful when trying to pop-up informations from a saturated result, consists in setting the Apex code filter level from DEBUG (which is default) to INFO and set the System to write my debugs in the less cluttered logging level, this way:

System.debug(LoggingLevel.INFO, myVar);
Categories: