Diagnosing Apex with debug logs and Replay Debugger
Trace the right entity (user, Automated Process, class or trigger), tune log levels to beat the 20 MB truncation, read the Log Inspector and Limits output, replay logs with checkpoints, and decode DmlException rows, exception emails, AsyncApexJob errors and test-only failures.
Given a scenario, Apex code, Apex trigger, or Apex tests that's not executing as expected, apply techniques tools to identify the cause.
~8 min read · 16 practice questions ·
What the exam expects
- Choose the trace flag that captures the failing transaction: a user (including an integration user), Automated Process for event subscribers, or a class or trigger override.
- Predict what a log contains from its debug levels, and fix logs that are truncated or too noisy.
- Locate slow code and limit consumption with the Log Inspector and the
Limitsmethods; inspect trigger context with Replay Debugger checkpoints. - Identify failing rows and jobs with
DmlExceptionmethods, exception emails,AsyncApexJobandsf apex tail log. - Explain test-only and trigger-skipping failures: Owner relationships in data-silo tests, the standard price book, cascade deletes and mixed DML.
Key terms: trace flag (an entity, time window and debug level that turns on logging); debug level (a log level per category such as Apex Code or Database); CLASS_TRACING (a class or trigger trace flag that overrides levels but never creates logs); checkpoint (a line where Replay Debugger captures a heap dump).
This unit assumes the Platform Developer guide's Debugging with logs and monitoring async jobs and flows (trace flag basics, reading a log, Developer Console).
Key facts
- Detail
- Overrides levels; never generates logs on its own
- Detail
- Called methods and triggers inherit the override unless they have their own
- Detail
- Created by Automated Process (or the overriding running user); not in the Developer Console Logs tab
System.debug default level- Detail
- DEBUG, unless a
LoggingLevelis passed
- Detail
- 20 MB per log; older lines removed above it
- Detail
- More than 1,000 MB in 15 minutes disables trace flags
- Detail
- Up to five; expire after 30 minutes; only place trigger context variables show
- Detail
- Timeline tab: milliseconds and percent of the request
- Detail
AsyncApexJob.NumberOfErrorsandExtendedStatus
- Detail
sf apex tail log
Sources for this section (8)
- Debug Log Levelshelp.salesforce.com (opens in a new tab)
- Debug Log Filtering for Apex Classes and Apex Triggershelp.salesforce.com (opens in a new tab)
- Set Up Debug Logs for Event Subscriptionsdeveloper.salesforce.com (opens in a new tab)
- Debug Logdeveloper.salesforce.com (opens in a new tab)
- Apex Replay Debuggerdeveloper.salesforce.com (opens in a new tab)
- Log Inspectorhelp.salesforce.com (opens in a new tab)
- AsyncApexJobdeveloper.salesforce.com (opens in a new tab)
- apex Commandsdeveloper.salesforce.com (opens in a new tab)
- Why does a CLASS_TRACING flag on its own produce no log?
- When must Replay Debugger checkpoints be uploaded?
- Why can a 20 MB log miss `System.debug` output from early in the transaction?
- Which `DmlException` method returns a failed row's position in the original list?
- Which Log Inspector views show where a slow save spent its time?
The questions are free to read. Answers with their sources and self-grading are included with the pack.
Keep reading with the Platform Developer II pack
- Core concepts
- Exam traps
- Worked scenario
The pack includes:
- All 28 lessons of the Platform Developer II guide, with reading progress
- Interactive decision walks and step-by-step sequence steppers
- Inline practice questions and one-click topic practice (16 questions for this lesson)
- An official source cited for every claim
- An AI tutor that answers from the guide
- Unlimited timed practice exams