Debugging In Salesforce - Part I
If you are ready to accept that your code can run into error, then debug logs can help you to find out the victim. Debug logs give all required information of a transaction to find out what is exactly happening when you perform any kind of action in Salesforce which includes database operation, system processes.You can set debug logs for users, classes and triggers.
Before moving ahead with how to capture debug logs, let’s understand few related terms which we will use while setting debug logs :
When monitoring debug logs you can specify what you want track or capture in that file. For this Log Category and Log Level helps.
- Log Category : With this you can mention what type of information you want to be logged, such as whether you want to get information about Apex or DML operations etc.
Category | Description |
---|---|
Database | This gives information about database operations performed during transaction, including every data manipulation language (DML) statement or inline SOQL or SOSL query. |
Apex Code | Includes information about Apex code. Can include information such as log messages generated by DML statements, inline SOQL or SOSL queries, the start and completion of |
System | Includes information about calls to all system methods such as the System.debug method. |
Workflow | Includes information for workflow rules, flows, and processes, such as the rule name and the actions taken. |
Visualforce | Includes information about Visualforce events, including serialization and deserialization of the view state or the evaluation of a formula field in a Visualforce page. |
Apex Profiling | Includes cumulative profiling information, such as the limits for your namespace and the number of emails sent, number of SOQL count, number of records retrieved in whole transaction. |
Validation | Includes information about validation rules, such as the name of the rule and whether the rule evaluated true or false. |
Callout | Includes the request-response XML that the server is sending and receiving from an external web service. Useful when debugging issues related to using Lightning Platform web service API calls or troubleshooting user access to external objects via Salesforce Connect. |
NBA | Includes information about Einstein Next Best Action activity, including strategy execution details from Strategy Builder. |
Again, to control how much information to be logged, debug levels come into the picture. With Log Levels you can set any one of the level for each category. From NONE to FINEST, each level has some defined events that can be logged. You can set these levels as per your need for debugging.
- NONE
- ERROR
- WARN
- INFO
- DEBUG
- FINE
- FINER
- FINEST
You can check what each level can track for each category by just selecting in debug levels.
And if you are selecting FINE level then all events of ERROR,WARN,INFO and DEBUG will also be tracked.
Let’s go ahead and dive into actual thing. To start capturing logs follow below steps:
- Go to Setup, and enter Debug logs in Quick Find
- Click on New in User Trace Flags.
- Now perform any operation, and you will find log file generated here on refresh.
- Click on View to see the file.
Click on save after filling required information. You’ll land on below screen
Comments
Post a Comment