You are here:
Debug Logs
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.
Required Editions
| Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience |
Available in: Performance, Unlimited, Developer, Enterprise, and Database.com Editions The Salesforce user interface, Email Services, and Approvals are not available in Database.com. |
| User Permissions Needed | |
|---|---|
| To view, retain, and delete debug logs: | View All Data |
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:
- Workflow rules
- Assignment rules
- Approval processes
- 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.
Transactions can be generated from the following:
- Salesforce user interface
- API
executeanonymouscalls- Web services
- Email services
The filter criteria set for the user, the Developer Console, or the API header determine what is included in the debug log.
The following are examples of when to use a debug log.
- 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.
Debug Log Limits
Debug logs have the following limits.
- 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.debugstatements. 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.
Warning If the debug log trace flag is enabled on a frequently accessed Apex class or for a user executing requests often, the request can result in failure, regardless of the time window and the size of the debug logs. - 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.
Debug Log Truncation
To provide the most pertinent information, debug logs are truncated, usually starting with older log entries. The newest log entries are always preserved. 200 KB of the debug log are deleted when the log reaches its maximum size of 20 MB.
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
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
Debug log filtering provides a mechanism for fine-tuning the log verbosity at the trigger and class level. - Set Up Apex Class and Trigger Trace Flags
You can set up an Apex class or trigger trace flag in Salesforce Setup, in the Developer Console, or by creating Tooling API objects with Salesforce CLI commands. These trace flags have the CLASS_TRACING debug log type and override the debug log levels of the USER_DEBUG and DEVELOPER_LOG trace flags.

