Need to get logfile smaller

I have a massive log file which breaks the 2Meg limit and hence truncates.

There is some information I need that I am logging by doing

System.debug

However, I don’t get to see because of the logfile truncation. I change the logging settings so that everything is logged at ERROR except apex code but this still does not bring logging under 2 Meg.

Any ideas?

Thanks.

Answer

There are various ways you can reduce your log file size.
The first step is to set the logging level on the important log statements to either Info, Warn or Error:

System.debug(LoggingLevel.Info, 'Important log message');

Then, reduce the logging level that gets captured. Such as setting class specific logging levels as per @Sdry’s answer.


Eclipse

If you are capturing the log via anonymous Apex execution you can alter the logging levels that get captured.

With Eclipse you could reduce the Apex Code category to Info and all other categories to None.
Eclipse Execute Anonymous Category Log Level

This should greatly reduce the size of your log.

You can do the same thing with running automated test cases.


Force.com Developer Console

With the Force.com Developer Console it is hidden under the Workspace (although I suspect it will be moving again with the Summer 13 release):

Force.com Developer Console Logging Levels


The log filters can also be altered from Setup > Administration Setup > Monitoring > Debug Logs. Then, under monitored users use the Filters link in the action column.

You might find it easier to just use the URL after replacing serverinstance and the user_id values:
https://serverinstance.salesforce.com/apexdebug/DebugUserLogSpecification.apexp?user_id=005fullUserId00

Monitoring Debug Log Event Filters


You can also alter these levels with the FuseIT SFDC Explorer (Full Disclosure: Shameless plug for a free tool I tinker with):

Anonymous Apex:
FuseIT SFDC Explorer Anonymous Apex Logging Levels

Apex Test Execution:
FuseIT SFDC Explorer Apex Test Logging Levels

Attribution
Source : Link , Question Author : More Than Five , Answer Author : Community

Leave a Comment