I wrote a simple program and want to see the output when I run the code. When I run it in the force.com IDE using the 'Annoymously execute apex code'command I get a lot of unwanted results, when I only want the system.debug statements. I could do use notepad or excel, but it seems like there should be a direct way (either native, or tool). Any advice?
Thanks,
code
public with sharing class Aa_playground {
public static void listExp(){
List<Integer> x = new List<Integer>();
x.add(1212);
for (Integer i = 0; i < x.size(); i++){
System.debug(x[i]);
}
}
}
output
Anonymous execution was successful.
24.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
Execute Anonymous: Aa_playground.listExp();
13:40:52.037 (37218000)|EXECUTION_STARTED
13:40:52.037 (37228000)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
13:40:52.037 (37634000)|METHOD_ENTRY|[1]|01pQ000000062u5|Aa_playground.Aa_playground()
13:40:52.037 (37726000)|METHOD_EXIT|[1]|Aa_playground
13:40:52.037 (37740000)|METHOD_ENTRY|[1]|01pQ000000062u5|Aa_playground.listExp()
13:40:52.037 (37920000)|USER_DEBUG|[9]|DEBUG|1212
13:40:52.037 (37947000)|METHOD_EXIT|[1]|01pQ000000062u5|Aa_playground.listExp()
13:40:52.594 (37979000)|CUMULATIVE_LIMIT_USAGE
13:40:52.594|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Number of script statements: 5 out of 200000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10
13:40:52.594|CUMULATIVE_LIMIT_USAGE_END
13:40:52.038 (38005000)|CODE_UNIT_FINISHED|execute_anonymous_apex
13:40:52.038 (38011000)|EXECUTION_FINISHED
To view a debug log, from Setup, enter Debug Logs in the Quick Find box, then select Debug Logs. Then click View next to the debug log that you want to examine.
In Apex, we have certain tools that can be used for debugging. One of them is the system. debug() method which prints the value and output of variable in the debug logs.
debug('The value is: ' + theValue); And then in your sidebar, under Administration go to Monitoring -> Debug Logs. You have to click on 'new' and add the user as whom the script will be running in order to capture the log output. Then after running the code, refresh the logs list and view the log to see the output.
I figured I'd sum up some of the info I found, in an answer.
^(?!.+USER_DEBUG.+$).*$
and paste it in the "Find What:" textbox.(?m)^([ \t\s]*|;.*)(\r?\n|$)
and paste it in the "Find What:" textbox.To execute your new macro, select Macro from the menu then click your macro name.
Credit for the regular expressions goes to nivyaj (see question comments). Daniel Ballinger's blog post was helpful as well.
This is probably bad practice, but what I have done in the past is set the log level of APEX_CODE to INFO and set the log level of the debug message to info as well
System.debug(Logginglevel.INFO, 'Debug Message with INFO level');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With