Table of Contents
Salesforce is a powerful platform, but troubleshooting issues can be challenging without the right tools. This is where Debug Logs in Salesforce come in. Debug logs help developers and administrators track system processes, troubleshoot errors, and optimize performance.
In this guide, we’ll explore what debug logs are, how to check, read, and delete them, and how they relate to key Salesforce components like Apex code, SOQL, Apex DML, Salesforce API, and governor limits.
What Are Debug Logs in Salesforce?
Debug logs are records that capture system events in Salesforce. They track user activities, system processes, and errors, helping developers analyze issues and fine-tune performance.
Why Are Debug Logs Important?
- Troubleshooting Errors – They help identify issues in Apex code, SOQL queries, and Apex DML operations.
- Monitoring Performance – Debug logs track execution times and governor limits to ensure your code runs efficiently.
- Tracking API Calls – They capture interactions with the Salesforce API, helping debug integration issues.
How to Check Debug Logs in Salesforce?
To access debug logs in Salesforce, follow these steps:
- Go to Setup – Navigate to Setup in Salesforce.
- Find ‘Debug Logs’ – Search for ‘Debug Logs’ in the Quick Find box.
- Select a User – Click “New” and select the user whose logs you want to capture.
- Start Logging – Perform the actions that need debugging.
- View the Logs – Refresh the Debug Logs page to see the recorded logs.

Alternatively, you can also use the Developer Console:
- Open the Developer Console.
- Click on Debug > View Log Panels.
- Perform the action you want to debug and check the logs in real time.

How to Read Debug Logs in Salesforce?
Debug logs contain a lot of technical information, so knowing how to interpret them is key. Here are the main sections of a debug log:
- Header: Contains metadata like the log timestamp, execution ID, and log level.
- Execution Events: Shows the order of events, such as Apex execution, SOQL queries, and governor limit checks.
- Errors and Warnings: Highlights any failures or warnings encountered.
- Debug Statements: Includes messages from System.debug() calls in Apex code.
Key Components of a Debug Log:
- EXECUTION_STARTED and EXECUTION_FINISHED – Marks the beginning and end of an execution.
- USER_DEBUG – Displays debug statements from your Apex code (System.debug() statements).
- SOQL_EXECUTE_BEGIN and SOQL_EXECUTE_END – Shows when a SOQL query runs.
- DML_BEGIN and DML_END – Logs Apex DML operations like insert, update and delete.
- LIMIT_USAGE_FOR_NS – Displays governor limit usage to track resource consumption.
Example Log Entry
14:15:10.001 (1010000)|USER_DEBUG|[10]|DEBUG|Account Name: Acme Corp 14:15:10.002 (1020000)|SOQL_EXECUTE_BEGIN|[15]|Aggregations:0|SELECT Name FROM Account WHERE Id = ‘001XXXXXXXXXXXX’ 14:15:10.005 (1050000)|SOQL_EXECUTE_END|[15]|Rows:1 14:15:10.007 (1070000)|DML_BEGIN|[20]|Op:Insert|Type:Account |
How to Delete Debug Logs in Salesforce?
Salesforce stores debug logs temporarily, but if you generate many logs, it’s good practice to clear them.
Steps to Delete Debug Logs:
- Go to Setup – Open Salesforce Setup.
- Search for ‘Debug Logs’ – Locate the Debug Logs page.
- Select Logs to Delete – Choose the logs you want to remove.
- Click Delete – Confirm the deletion.
You can also use Apex code or Salesforce API to delete logs programmatically.

Understanding Governor Limits in Debug Logs
Salesforce enforces governor limits to ensure system performance and fair resource usage. If your code exceeds these limits, it will fail. Debug logs help track:
- SOQL Limits: Maximum 100 queries per transaction.
- DML Limits: Maximum 150 DML operations per transaction.
- Heap Size Limits: Maximum 6MB for synchronous transactions.
- CPU Time Limits: Maximum 10,000 milliseconds.
If a debug log shows an error like System.LimitException: Too many SOQL queries, it means your code needs optimization.

Best Practices for Using Debug Logs in Salesforce
To make the most of debug logs, follow these best practices:
1. Use Debug Logs Wisely
Avoid enabling debug logs for too many users at once. This can slow down system performance.
2. Set Log Levels Appropriately
Salesforce allows different log levels, such as:
- ERROR: Logs only critical issues.
- DEBUG: Captures detailed execution flow.
- FINEST: Records everything, including low-level system events.
Use ERROR or DEBUG levels for most troubleshooting tasks to reduce unnecessary log size.
3. Monitor Governor Limits
Check logs for governor limit warnings to prevent runtime failures. Optimize SOQL queries, Apex DML operations, and loops to stay within limits.
4. Automate Log Cleanup
If logs aren’t needed, delete them periodically to save storage.
5. Use Trace Flags for Targeted Debugging
Instead of logging everything, enable trace flags for specific users or processes to capture only relevant data.

Winding Up
Debugging logs in Salesforce are key for troubleshooting purposes and performance enhancements. They facilitate the assessment of Apex code running, SOQL queries, Apex DML operations, and governor limits. Knowing how to check debug logs in Salesforce, how to read them, and how to delete them will help developers and administrators keep the system running smoothly.
Proper use of debug logs will give you the opportunity to fix a problem, optimize a piece of code, or save the consideration of a system failure. Learning debug logs, whether for debugging an Apex trigger or for keeping track of Salesforce API call records, will prove your worth as a Salesforce professional.
Join our newsletter: Get daily update on Salesforce career insights & news!
Join Now!