Reading Debug Logs
By the end of this lesson, you'll be able to:
- Locate a debug log after running Apex code
- Identify a USER_DEBUG line in a log
- Explain why logs contain far more than just your own debug statements
Prerequisites: "Execute Anonymous"
Where logs come from
Every time you run Apex — through Execute Anonymous, a trigger firing, or a test — Salesforce can capture a log of exactly what happened. In the Developer Console, these appear in the Logs tab at the bottom of the window automatically after each run.
Finding your own output in the noise
Open any log and you'll see a wall of text. Most of it is Salesforce's own internal tracking (governor limit usage, validation rule evaluation, and so on) — genuinely useful once you know how to read it, but not what you're looking for on day one.
Search (Ctrl+F / Cmd+F) for USER_DEBUG — that's the exact line type your own System.debug() calls produce. It'll look something like:
15:32:07.100 (100200300)|USER_DEBUG|[2]|DEBUG|Hello, Salesforce!
The [2] is the line number in your code that produced it — genuinely useful when you have several debug statements and need to know which one fired.
Common mistakes
- Giving up because the log "has too much stuff in it." Searching for
USER_DEBUGsolves this immediately — you rarely need to read a log top to bottom. - Not realizing a log was truncated. Very large logs get cut off; if your expected output is missing entirely, this is worth checking (Setup → Debug Logs → log size).
Exercise
Run the Greeter class from the Developer Console lesson again, then open its log and find your USER_DEBUG line using search.
Show hint
Ctrl+F (Windows) or Cmd+F (Mac) opens search within the open log.
Reading Debug Logs Quiz
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 debug log is a detailed, timestamped record of everything that happened during one execution — not just your own System.debug() lines, but every governor-limit check, SOQL query, and DML statement along the way, which is exactly why they can feel overwhelming at first.