1

Got a system.debug() inside a trigger handler.

When running test class, nothing is output to log. Works when trying the same in UI.

What could be the problem?

Checked my test class overrides to no avail. Somehow for one test run, it did manage to log some debug statements from invoked utility class, but not from actual handler. Mystery. Confusion.

3
  • Can you make sure that the test class performing the DML on same object and even on which trigger is written? – Ashwani Jun 23 '15 at 6:24
  • It does. The trigger does work, I can see bunch of SOQL queries, etc. It has loads of debug statements of which none appear in log. And especially the ones I need! – dzh Jun 23 '15 at 9:56
  • 1
    I've started using asserts when the debug logs get too big. Adding something like System.assert(false, 'The value of x is ' + x); will stop the logic in its tracks and display your message on the screen. – BarCotter Jun 23 '15 at 10:01
0

I would suspect that the issue is due to your log levels being set to something above "debug". With the log levels, you can set specific classes (e.g. the test class) to different log levels than everything else. I would recommend that you set your logging level to error (the highest level available, meaning the least amount of detail), you can do that by:

system.debug(LoggingLevel.Error,'My Debug Statement');

The advantage to using the logging level of error is that it enables you to view the debugs even if your logging level is not set to debug for apex.

1
  • Sorry that did not help. – dzh Jun 23 '15 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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