Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose I have a test class TestClassName.

private class TestClassName {
static testMethod void testMethodName() {
        System.debug('My debug statement');
        System.assertEquals(1, 1);

Where can I find the log that has the 'My debug statement' output?

It seems that:

  • shows the log of the actual ClassName class
  • Developer console shows the log of the actual ClassName class
  • Debug Logs doesn't show the logs of the TestClassName test class
  • Apex Test Execution doesn't show any logs
share|improve this question
You should be able to see the logs of the test class in the developer console, monitored debug logs, and if you are running the tests from eclipse the eclipse test results window. This is probably an issue with your log levels but can you write up how you are running the tests to help us troubleshoot. – Greg Grinberg Feb 14 '13 at 16:07
up vote 5 down vote accepted

When you run your test class the debug log does show the logs of even your test execution.

You have to find the user that started the test in question. The user can be found by going to Setup > Develop > Apex Test Execution and inspecting the Test run to find the email of the user.

The line will look like this:

Test run: yyyy-mm-dd hh:MM:ss, (n class[es])

Then at Setup > Monitoring > Debug Logs add the user who has the email to Monitored Users.

 07:54:37.375 (2375302000)|EXECUTION_STARTED
 07:54:37.375 (2375362000)|CODE_UNIT_STARTED|     [EXTERNAL]|01p90000002IZE6|TestClassName.testMethodName
  07:54:37.376 (2376542000)|METHOD_ENTRY|   [2]|01p90000002IZE6|TestClassName.TestClassName()
 07:54:37.376 (2376557000)|METHOD_EXIT|[2]|TestClassName
 07:54:37.376 (2376695000)|SYSTEM_METHOD_ENTRY|[4]|System.debug(ANY)
  07:54:37.376 (2376721000)|USER_DEBUG|[4]|DEBUG|My debug statement
  07:54:37.376 (2376731000)|SYSTEM_METHOD_EXIT|[4]|System.debug(ANY)
  07:54:37.376 (2376752000)|SYSTEM_METHOD_ENTRY|[5]|System.assertEquals(ANY, ANY)
  07:54:37.376 (2376776000)|SYSTEM_METHOD_EXIT|[5]|System.assertEquals(ANY, ANY)
   07:54:35.608 (2376798000)|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 code statements: 2 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


07:54:37.376 (2376826000)|CODE_UNIT_FINISHED|TestClassName.testMethodName
07:54:37.376 (2376835000)|EXECUTION_FINISHED
share|improve this answer
Can you share step-by-step instructions to get to the log? If I add the appropriate user to Monitored Users, the logs still don't show any activities at the time of tests. – ipavlic Feb 14 '13 at 15:48
Its very simple.First you have to find the User for which you are running test class.In debug log set that user and refresh.I have updated my answer too with debug log i obtained for your class.Hope it helps – Mohith Shrivastava Feb 14 '13 at 15:59
Hint the logs never showed any activity signifies that he is not the right user . – Mohith Shrivastava Feb 14 '13 at 16:03
You are right! I had to put the user who started the test to Monitored Users. One can find that user on the Test Run: [date time], [email] line at Apex Test Execution. – ipavlic Feb 14 '13 at 16:06
Happens !Glad that i was able to help:) – Mohith Shrivastava Feb 14 '13 at 16:07

Launch your Devloper Console (Username>Developer Console)

Go to Setup>Developer>Apex Test Execution>Select Tests> pick the testing class you want to see the debug logs from can click run.

Go to your Dev Console. In the logs section you will see the ApexTestHandler operation. Double click that log. Then check 'Debug Only'. You will see your System.debug lines.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.