function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RohiniHRohiniH 

How to capture all debug log exceeding 2mb limit

Hi,
Whenever the debug log exceeds 2mb limit, salesforce skip the debug log statements, and prints the trailing debug log statements in the debug file.Is there any way where we can capture all the system.debug statements  if the debug log file exceeds 2mb limit.
 say in developer console following 2 for loop snippets are executed separately
for(Integer i=0;i<100;i++){
    System.debug('hello  : '+i);
}

for(Integer i=0;i<10000;i++){
    System.debug('hello  : '+i);
}
For the later ..
33.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
17:02:22.017 (17905870)|EXECUTION_STARTED
17:02:22.017 (17915505)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
*** Skipped 1399744 bytes of detailed log
17:02:22.176 (176450640)|SYSTEM_METHOD_ENTRY|[2]|System.debug(ANY)
17:02:22.176 (176460570)|USER_DEBUG|[2]|DEBUG|Hello count4176
17:02:22.176 (176464556)|SYSTEM_METHOD_EXIT|[2]|System.debug(ANY)
17:02:22.176 (176478193)|SYSTEM_METHOD_ENTRY|[2]|String.valueOf(Object)
17:02:22.176 (176490390)|SYSTEM_METHOD_EXIT|[2]|String.valueOf(Object)
17:02:22.176 (176497639)|SYSTEM_METHOD_ENTRY|[2]|System.debug(ANY)
.....

Kind regards,
Ruhi.
ShashankShashank (Salesforce Developers) 
Here are a couple of ideas around this limitation that you can promote:
https://success.salesforce.com/ideaView?id=087300000006n4ZAAQ
https://success.salesforce.com/ideaView?id=08730000000YcMDAA0