Salesforce provides debug logs to track the events occurring in a Salesforce organization. It contains information about the transactions such as whether it was successful and how much time it took to complete the transaction. Debug logs are generated based on the ‘User Trace Flag’ in Debug Logs. Debug logs are generated by the system when a user performs a transaction. This is a very useful feature for Salesforce developers and integration partners.
What is a Trace Flag?
Trace flag are used to filter the log. Each trace flag includes a debug level, start time, end time, and log type. The trace flag’s log type specifies the entity you’re tracing. Below are the steps to create a Trace Flag:
- Navigate to setup and search for ‘Debug Logs’ in the quick find box. On selecting the ‘Debug Logs’ below screen will be shown
- Click on ‘New’ button. You will be navigated to below screen where you need to provide below details :
- Traced Entity Type – If you want to generate debug logs for a User select User from the drop-down list. Select Apex Class or Apex Trigger from the drop-down list to specify the log levels that take precedence while executing a specific Apex class or trigger. If you want to set a trace flag on the automated process user, Select automated process. The automated process user runs background jobs, such as emailing Chatter invitations.
- Traced Entity Name Select the entity for which you want to create the Debug Log.
- Start Date Select the date from which you want to generate the debug log.
- Expiration Date Select the date after which you want to end the debug log.
- Debug Level It specifies the type of information that is logged for different events. Salesforce provides a default log level, that is ‘SFDC_DevConsole’. You can also create a new Debug Log Level based on your requirement
- Click on ‘Save’ button. Now a trace flag is created.
Debug Log Category
Information is logged based on the category called Log Category. Below are the different log categories
|Database||Includes information about database activity, including every data manipulation language (DML) statement or inline SOQL or SOSL query.|
|Workflow||Includes information for workflow rules, flows, and processes, such as the rule name and the actions taken.|
|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.|
|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 any triggers, and the start and completion of any test method.|
|Apex Profiling||Includes cumulative profiling information, such as the limits for your namespace and the number of emails sent.|
|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.|
|System||Includes information about calls to all system methods such as the System.debug method.|
Log level determines the amount of information logged when an event is triggered. There are different log levels for each log category. The levels are listed below from lowest to highest.
|Error, Warn, Info||Includes error, warning, and information messages.|
|Debug||Includes lower-level messages, and messages generated by calls to the System.debug method.|
|Fine, Finer||Includes log messages generated by calls to the System.debug method, every DML statement or inline SOQL or SOSL query, and the entrance and exit of every user-defined method. In addition, the end of the debug log contains overall profiling information for the portions of the request that used the most resources. These resources include SOQL and SOSL statements, DML operations, and Apex method invocations.|
|Finest||Includes all messages generated by the Fine or Finer log levels, as well additional information on Apex scripts, including the following.|
The level is cumulative, which means when a level is selected all the levels above that are also logged. If you select DEBUG, the log also includes all events logged at the INFO, WARN, and ERROR levels.
Limitations of a Debug Log
- Each debug log must be 5 MB or smaller. Debug logs that are larger than 5 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.
- Trace flag will be disabled when a debug log more than 250 MB is generated in a 15-minute window. An email will be sent to the user who last modified the trace flag so that, they can re-enable it.
- When your org accumulates more than 250 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.
About us and How we can help
Our team can help you customize and integrated Salesforce as per your business process. Read about our Salesforce Integration Services. Reach out to us for a free assessment of your business needs.