Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I wrote a simple program and want to see the output when I run the code. When I run it in the 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?




public with sharing class Aa_playground


 public static void listExp(){

    List<Integer> x = new List<Integer>();


    for (Integer i = 0; i < x.size(); i++){





Anonymous execution was successful.


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


  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.038 (38005000)|CODE_UNIT_FINISHED|execute_anonymous_apex

13:40:52.038 (38011000)|EXECUTION_FINISHED

1 Answer

0 votes
by (32.1k points)
edited by

Hi, to solve this problem, you can use Notepad++. To do so, download Notepad++ v6.1+ and paste your debug log file in it. Open menu and select Macro > Start Recording. Then, press CTRL+H (a shortcut for Search and Replace). Copy this expression:  ^(?!.+USER_DEBUG.+$).*$  and paste it in the ‘Find What:’ textbox.  Now, set the search mode to Regular expression and then make sure that the ‘Replace With:’ textbox is blank. Now, click on ‘Replace All’ and then click on ’OK’ when the resulting dialog appears. Copy this regular expression (?m)^([ \t\s]*|;.*)(\r?\n|$) and paste it in the ‘Find What:’ textbox. Set the search mode to Regular Expression and the ‘Replace With’ textbox to blank. Click "Replace All" and "Ok". Then, close the Search and Replace dialog. From the menu, select Macro > Stop Recording. Then select Macro > Save Current Recorded Macro. Enter a Name for your new macro, and optionally set the shortcut keys. Then click "Ok".

To execute your new macro, select Macro from the menu then click your macro name.

Want to become a Salesforce expert, join Salesforce Online Training now!

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

29.3k questions

30.6k answers


104k users

Browse Categories