Debug Log
Debug Log
Use debug logs to track events that occur in your org. Debug logs are generated when you have active
user-based trace flags, when you run Apex tests, and when executed code or API requests include
debugging parameters or headers.
A debug log can record database operations, system processes, and errors that occur when executing a transaction or
running unit tests. Debug logs can contain information about:
Database changes
HTTP callouts
Apex errors
Resources used by Apex
Automated workflow processes, such as:
o Workflow rules
o Assignment rules
o Approval processes
o Validation rules
NOTE The debug log does not include information from actions triggered by time-based workflows.
The system generates a debug log every time a transaction that is included in the defined filter criteria is
executed.
The filter criteria set for the user, the Developer Console, or the API header determine what is included in
the debug log.
NOTE Debug logs don’t include transactions that lead conversion triggers. For example, suppose that a converted lead
triggers a workflow rule. The debug log doesn’t show that this workflow rule fired.
As a developer creating a custom application, you can use the debug log to validate the application’s behavior.
For example, you can set the debug log filter to check for callouts. In the resulting debug log, you can view
information about the success and duration of those callouts.
As an administrator for an org, you can use the debug log to troubleshoot when a user reports difficulty. Set a
trace flag on the user, ask the user to step through the problematic transaction, and then use the debug log to
view the system details.
For user-based trace flags, enter Debug Logs in the Quick Find box, then click Debug Logs.
For class-based trace flags, enter Apex Classes in the Quick Find box, click Apex Classes, click
the name of a class, then click Trace Flags.
For trigger-based trace flags, enter Apex Triggers in the Quick Find box, click Apex Triggers,
click the name of a trigger, then click Trace Flags.
Each debug log must be 20 MB or smaller. Debug logs that are larger than 20 MB are reduced in size by
removing older log lines, such as log lines for earlier System.debug statements. The log lines can be removed
from any location, not just the start of the debug log.
System debug logs are retained for 24 hours. Monitoring debug logs are retained for seven days.
If you generate more than 1,000 MB of debug logs in a 15-minute window, your trace flags are disabled. We
send an email to the users who last modified the trace flags, informing them that they can re-enable the trace
flag in 15 minutes.
When your org accumulates more than 1,000 MB of debug logs, we prevent users in the org from adding or
editing trace flags. To add or edit trace flags so that you can generate more logs after you reach the limit, delete
some debug logs.
The following events are necessary for processing the debug log, so they’re not deleted during truncation.
EXECUTION_STARTED
EXECUTION_FINISHED
CODE_UNIT_STARTED
CODE_UNIT_FINISHED
METHOD_ENTRY
METHOD_EXIT
CONSTRUCTOR_ENTRY
CONSTRUCTOR_EXIT
SOQL_EXECUTE_BEGIN
SOQL_EXECUTE_END
SOSL_EXECUTE_BEGIN
SOSL_EXECUTE_END
CALLOUT_REQUEST
CALLOUT_RESPONSE
FATAL_ERROR
NOTE Log entries for events that are necessary for processing the debug log aren’t truncated. However, other log
information that appears between the start and end lines of these log entries is removed during log truncation.
Debug Log Details
A debug log includes a header, execution units, code units, log lines, and other log data.
Debug Log Order of Precedence
Which events are logged depends on various factors. These factors include your trace flags, the
default logging levels, your API header, user-based system log enablement, and the log levels set
by your entry points.
Debug Log Levels
To specify the level of information that gets included in debug logs, set up trace flags and debug
levels. The debug levels assigned to your trace flags control the type and amount of information
that is logged for different events. After logging has occurred, inspect debug events in your debug
logs.
Searching a Debug Log
To search for text in a debug log, use the Command Line Window in the Developer Console.
Delete Debug Logs
When your org accumulates too many debug logs, delete some or all of your system logs and
monitoring logs. Use the Developer Console’s Query Editor to find and delete the logs using
Tooling API.
Debug Log Filtering for Apex Classes and Apex Triggers
NONE
ERROR
WARN
INFO
DEBUG
FINE
FINER
FINEST
What is the minimum log level needed to see user -generated debug statements? DEBUG