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
Steven HoughtalenSteven Houghtalen 

Developer Console - system debug statement

When I place a system.debug statement inside a method, it doesn't show up in the log.  If it is not inside a method, it works fine.  Am I doing something wrong?
Best Answer chosen by Steven Houghtalen
V V Satyanarayana MaddipatiV V Satyanarayana Maddipati
Hi Steven,

Looks like you are executing(Click on Execute button) the method from the developer console,  which means the code inside the method is getting compiled(Checks only for the syntaxes) & it won't run the code.

To run the code you want to call  the method from the developer console.
For eg, if you have below method in your developer console.
public void method1() {

    system.debug('Hello World');
}
To run the above method , Call the method as mentioned here :  method1();
Now execute your code in the developer console, which will run the code and will pring debug statement in the log.


Thanks
Satya.

All Answers

Rashi Garg 30Rashi Garg 30
Hi Steven,

It may happen that your method is not getting exceuted or your excution is not getting reached till that debug line. 

You can see the line numbers in debug log to take the idea of the lines that are getting exectued.

Hope this helps.

Thanks,
Rashi
V V Satyanarayana MaddipatiV V Satyanarayana Maddipati
Hi Steven,

Looks like you are executing(Click on Execute button) the method from the developer console,  which means the code inside the method is getting compiled(Checks only for the syntaxes) & it won't run the code.

To run the code you want to call  the method from the developer console.
For eg, if you have below method in your developer console.
public void method1() {

    system.debug('Hello World');
}
To run the above method , Call the method as mentioned here :  method1();
Now execute your code in the developer console, which will run the code and will pring debug statement in the log.


Thanks
Satya.
This was selected as the best answer