[SalesForce] System.debug is not displaying output
I am unable to print the message in the with System.debug;
I given as
System.debug('Hello SFDC');
Best Answer
Messages logged via System.debug() don't appear along with the output of any test executions, VisualForce pages, etc. but are visible via debug logs. You'll need to enable debug logs for your user account before running the Apex code which triggers System.debug(), and then debug logs will be saved for the next 20 operations you perform, whether or not they cause any System.debug() calls.
Debug logs can be quite dense, and locating a specific piece of information in them can be difficult. I recommend making your System.debug() text very unique so you can easily search through the log. For example, instead of just debug logging an sObject ID, log it with some prefix (e.g., System.log('My object ID: ' + obj.id)) so you can search the log for that prefix (in this example case, you'd search for “My object ID:”).
As @crop1645 commented, if the Apex Code logging level is set to high on the general trace settings or on the Builder class the log message won't appear. By default System.debug will log at the Debug level.
In the Developer Console, check your Apex Code Log Levels are Debug or lower. Check Both the General Trace Settings for User and for any Class specific traces for Builder.
You could try using a higher logging level:
System.debug(LoggingLevel.Error, 'Rabbit Army');
Or really prove it is being called by making a failing assertion:
Best Answer
Messages logged via
System.debug()
don't appear along with the output of any test executions, VisualForce pages, etc. but are visible via debug logs. You'll need to enable debug logs for your user account before running the Apex code which triggersSystem.debug()
, and then debug logs will be saved for the next 20 operations you perform, whether or not they cause anySystem.debug()
calls.Debug logs can be quite dense, and locating a specific piece of information in them can be difficult. I recommend making your
System.debug()
text very unique so you can easily search through the log. For example, instead of just debug logging an sObject ID, log it with some prefix (e.g.,System.log('My object ID: ' + obj.id)
) so you can search the log for that prefix (in this example case, you'd search for “My object ID:”).