Friday, 28 May 2021

Salesforce Debug Logs

 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.


1.Debug logs are used to track the events information that occurs in your org.

2.Debugs log, will only be generated when you have an active flag turned on for the logged in user.


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.


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


Salesforce Debug Log Levels :


you can also specify one of the following logging levels.


1.NONE

2.ERROR

3.WARN

4.INFO

5.DEBUG

6.FINE

7.FINER

8.FINEST


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.


what do you do when your debug session reaches 2MB?


There are only a few options


1.Reduce the log level details for the user you're debugging.

2.Trace flag the noisiest classes into submission.


Trace Flags :


In order to generate debug logs, we need to set trace flags.

Trace Flags can be set for Apex Classes ,Triggers and Users.


Limitations of a Debug Log :


1.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.

2.System debug logs are retained for 24 hours. Monitoring debug logs are retained for seven days.

3.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.

4.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.

No comments:

Post a Comment