Intermediate 25 min read

Reading a Debug Log Under Pressure

By the end of this lesson, you'll be able to:

  • Scan a debug log efficiently for the relevant section rather than reading top to bottom
  • Recognize the key log line types: USER_DEBUG, SOQL_EXECUTE_BEGIN, DML_BEGIN, EXCEPTION_THROWN
  • Apply this skill to a realistic "something broke in production" scenario

Prerequisites: "Debug Log Levels"

The key line types worth recognizing

13:42:01.1 (1234567)|USER_DEBUG|[42]|DEBUG|Processing 200 accounts
13:42:01.2 (2345678)|SOQL_EXECUTE_BEGIN|[45]|Aggregations:0|SELECT Id, Name FROM Account
13:42:01.3 (3456789)|DML_BEGIN|[52]|Op:Update|Type:Account|Rows:200
13:42:01.5 (5678901)|EXCEPTION_THROWN|[58]|System.NullPointerException: Attempt to de-reference a null object

USER_DEBUG is exactly your own System.debug(...) output. SOQL_EXECUTE_BEGIN and DML_BEGIN mark exactly where a query or DML statement ran — genuinely useful for confirming a suspected SOQL-in-a-loop problem (Module 25) actually happened. EXCEPTION_THROWN marks precisely where and what broke.

Scanning, not reading

Under real time pressure, searching a log file for EXCEPTION_THROWN first (jumping straight to the failure) is far faster than reading from the top — then working backward from that line to see what led up to it. Most debug logs are read this way: locate the failure, then trace its immediate context, not consumed start to finish like a narrative.

A realistic scenario, traced

13:42:01.4 (4567890)|USER_DEBUG|[55]|DEBUG|About to process account: null
13:42:01.5 (5678901)|EXCEPTION_THROWN|[58]|System.NullPointerException: Attempt to de-reference a null object

Scanning for EXCEPTION_THROWN, then looking one or two lines above it, immediately reveals the cause here: a null account reached line 58, and the line just before confirms it — the exact debugging shortcut this lesson exists to teach.

Exercise

As a comment, describe the two-step scanning strategy for finding the cause of a production error in a large debug log.

Show hint

Search for something specific first, then work backward.

APEX

Reading a Debug Log Under Pressure Quiz

1. What does the EXCEPTION_THROWN line in a debug log mark?

Log in to submit the quiz and save your score.

My Notes

Log in to keep private notes on this lesson.

Questions about this lesson

No questions yet — be the first to ask.

Log in to ask a question about this lesson.

Summary

A real debug log can run thousands of lines — this lesson covers scanning it efficiently under time pressure, rather than reading it top to bottom like a book.