Apr 26, 2011

System Debug

Its very hectic to debug when we have too many script statements. Most of the time when we apply System.debug in our code with many script statement we get :


*********** MAXIMUM DEBUG LOG SIZE REACHED ***********


I get frustrated with this and started rolling over the pdf which says there is a solution for this. Now if I want to see a specific line debug which is coming almost in the end of our code so I will simply write this where I want to get the debug in my code :
System.debug(Logginglevel.ERROR , ' ::::::: My Debug :::::::::::::') ;
And after this some steps to be done
  1. Create Debug logs from "Monitoring"
  2. Create Filters :
    • Database : NONE
    • Workflow : NONE
    • Validation : NONE
    • Callouts : NONE
    • Apex Code : ERROR
    • Apex Profiling : NONE
    • Visualforce : NONE
So when I execute my code only debug with Logginglevel.ERROR will be displayed. Isn't this useful. 

Enjoy the power of salesforce.

5 comments:

  1. Enjoy the power of salesforce

    ReplyDelete
  2. Hi,



    I am running unit tests and I need to see values at few places.

    So I have used debug statements similar to below one at lot of places:

    system.debug(Logginglevel.ERROR,'message no # 1');


    Still I am not able to see the messages in debug log b/c of max debug log size issue.

    I also went to developer console - > workspace: Default -> Change log levels -> I have changed every one to ERROR level.

    Once I ran the test class and see log file in (set up-> monitoring->debug logs) on the first line of the file I see below details

    "24.0 APEX_CODE,FINE;APEX_PROFILING,FINE;DB,INFO;VALIDATION,INFO;WORKFLOW,FINEST"

    I am not sure why the levels are not changed in the above debug log.Please help me on this.

    Thanks,
    JBabu.

    ReplyDelete
  3. Babu, did u find a solution? i'm in same situation currently

    ReplyDelete
  4. We can't set Debug Log Level in Test Mode. I'm unable to find the official documentation for this.....but you can test for yourself

    ReplyDelete