Loading
Help Agent Performance DegradationRead More

How to Capture Salesforce Debug Logs for Troubleshooting

Publish Date: Jan 21, 2025
Description

Sometimes it is necessary when troubleshooting Salesforce automations or trying to find out why things are functioning differently than normal such as cases getting auto closed to run debug logs. Debug logs allow you to see exactly what is happening when Salesforce is executing your business logic. This guide will help you capture a debug log to analyze.

Resolution

Turn on Debug Logs
 

1. Open Salesforce Setup
2. Search Debug in the quick find.
3. Select Debug Logs.
4. Create a New debug Level.
a.) Set a name like: Acme_Automation_Debug
b.)  Set the level based on what you are trying to troubleshoot. 
 i.) For Flows and Process Builder, Set "Workflow" to Finer
ii.) For Apex and Triggers, set "Apex Code" to Finest
c.)  Click on Save

12.png

5. Activate a log for a user and select the debug level you created. 
a.) Traced Entity type: User
b.) Traced Entity Name: User who will be doing the action to test. 
c.) Start Date: Current Date/Time. 
d.) Debug level: Use debug level name created above. 
 

Debug Logs.png

Recreate the issue
 

1. Perform the action that you are troubleshooting. 
a.) Record triggered flow: Create, update or delete a record that will trigger the flow. 
b.) Screen flow: launch the screen flow like normal
c.) Trigger: create, update or delete a record based on the apex trigger.
2. Go back to debug logs in setup and you will see logs recorded. 
a.) Look for logs that are larger in size; generally the ones with more content in them are related to what you tested. 
b.) You can download and view with a text editor or share with the TBC or developer to help troubleshoot. 

Reading the Debug Log

Reading the Debug Log can be the key to figuring out what is happening, but can also be hard to understand when there are a lot of things in them. Below is a list of some of the common things to keep an eye out for and how to interpret them if you come across them. 
 

ENTERING_MANAGED_PKG: This means the code is executing logic from a managed package from the Appexchange. There is no way to see exactly what is happening because that code is protected.

LIMIT_USAGE_FOR_NS: This will generally be followed by the limits that the transaction is currently at for the particular name space. This can be helpful to see if there are issues with hitting governor limits.

SOQL_EXECUTE_BEGIN: This is going to be when a SOQL query is executed by the code. This can show what the exact query is to see if it is not formed correctly.

SOQL_EXECUTE_END: This can be found generally after a SOQL Execute Begin and it will show the number of rows returned from the SOQL query. If the number of rows is 0 that means no records were found

FLOW_CREATE_INTERVIEW_BEGIN: This will be used at the start of a flow and can help to identify the start of the flow interaction.

FLOW_INTERVIEW_FINISHED_LIMIT_USAGE: When troubleshooting governor limits related to record-triggered flows, looking for this event can be informative to see what the limits were at the end of a flow transaction.

FATAL_ERROR: This can be caused by numerous things, but seeing it can generally indicate that something preceding it in the debug log caused the error.

DML_BEGIN: This means that some type of insert or update records is taking place. There will be an identifier that will specify the DML operation being performed.
 
There are many other events that you will see in the debug logs. A full list of them can be found here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_debugging_system_log_console.htm

 

Automated Users
 
The standard "debug logs" page does not allow you to set up a debug log for certain users, such as the S2S connection users or automated users.  To see more information, visit Debug a System User.

 

 

 

Additional Resources

 

 

Knowledge Article Number

000392579

 
Loading
Salesforce Help | Article