Debugging In Salesforce - Part II


Hope you have read Part I of this series !!

In this part we'll understand how to read log file.

Once you capture a log file and open it, you can get all information from first line itself.
  • First line of log gives information about the log categories and levels and Second line gives User Information


  • EXECUTION_STARTED marks the start of transaction.
  • CODE_UNIT_STARTED and CODE_UNIIT_FINISHED marks start and end of particular code unit which was executed during transaction. Using this you can check what has happened when particular unit of code executed.
    Units of code include, but are not limited to, the following:
    1. Triggers
    2. Workflow invocations and time-based workflow
    3. Validation rules
    4. Approval processes
    5. Apex lead convert
    6. @future method invocations
    7. Web service invocations
    8. executeAnonymous calls
    9. Visualforce property accesses on Apex controllers
    10. Visualforce actions on Apex controllers
    11. Execution of the batch Apex start and finish methods, and each execution of the execute method
    12. Execution of the Apex System.Schedule execute method
    13. Incoming email handling
  • Each log line has predefined format
    • Timestamp : Consists of the time when the event occurred and a value between parentheses. The time is in the user’s time zone and in the format HH:mm:ss.SSS. The value in parentheses represents the time elapsed in nanoseconds since the strt of the request.
    • Event Identifier : Specifies the event that triggered the debug log entry (such as SAVEPOINT_RESET or VALIDATION_RULE).
      Also includes additional information logged with that event, such as the method name or the line and character number where the code was executed.


Here 13:44:17.0 (1236238) is a timestamp and part after | gives information about the event that it’s a user debug statement at line number 3 followed debug string.

Similarly, you can read each line of log file for every event.

Some Useful Tips :


Ø  To see SOQL results search with SOQL_EXECUTE_BEGIN(Database Category),  This will show query string that was executed and next line to this will show number of records retrieved by query without placing System.debug statement.

Ø  Search with DML_BEGIN(Database Category) to check status of your DML operation

Ø  Search with CUMULATIVE_LIMIT_USAGE (Apex Profiling Category)  to get information about limit usage during transaction

Ø  WF_RULE_EVAL_BEGIN(Workflow Category) gives information about workflow rules.
WF_CRITERIA_BEGIN – Specifies name and Id of workflow rule being evaluated
WF_FORMULA – Formula of entry criteria
WF_CRITERIA_END|true – This marks the end of workflow rule evaluation along with Boolean value specifying whether entry criteria was satisfied or not.

Ø  WF_FIELD_UPDATE(Workflow Category) gives information about Field Updates that were carried out during transaction.

Ø  USER_DEBUG (Apex Code Category) to check System.debug statements if you have added any.

Comments

Popular posts from this blog

Salesforce Flow - Create multiple records from user input

Scan barcodes from Salesforce Mobile App

Zip or Unzip Files in Salesforce