Troubleshooting Automation with Debug Logs

5 minutes 5 Questions

Troubleshooting automation with Debug Logs is a core skill for a Salesforce Platform Administrator II, especially when flows, approval processes, validation rules, or Apex triggers behave unexpectedly. Debug Logs capture a detailed, chronological record of what happens on the platform during a transaction, letting you see exactly which automations fired, in what order, and where errors occurred. To begin, navigate to Setup > Debug Logs and create a Trace Flag. A trace flag specifies the traced entity (a user, Apex class, or Apex trigger), a start and expiration time, and a Debug Level. The Debug Level controls verbosity across categories such as Workflow, Apex Code, Database, Validation, Callouts, and System. For automation troubleshooting, set Workflow to FINER or FINEST to capture flow and process details, and Apex Code to DEBUG or higher if triggers are involved. Keep other categories lower to avoid hitting the 20 MB per-log limit or the 1,000 MB per-org retention limit. Once the trace flag is active, reproduce the issue by performing the action as the traced user. Then open the generated log and review key events: CODE_UNIT_STARTED and CODE_UNIT_FINISHED show entry and exit points, FLOW_START_INTERVIEW and FLOW_ELEMENT_BEGIN reveal which flow elements executed, WF_RULE_EVAL_BEGIN shows workflow and approval evaluation, VALIDATION_RULE shows pass/fail outcomes, and DML_BEGIN shows record operations. Lines containing FATAL_ERROR or EXCEPTION_THROWN pinpoint failures such as null references, unhandled faults, or governor limit violations. The LIMIT_USAGE_FOR_NS section helps identify SOQL query, DML statement, or CPU time overages caused by recursive automation. Best practices include understanding the order of execution (validation rules, before-triggers, after-triggers, assignment rules, record-triggered flows, workflow, escalation rules), checking Setup Audit Trail for recent changes, using Flow Debug mode alongside logs, and leveraging the Developer Console's Log Inspector for filtering and timeline views. Delete expired trace flags afterward to preserve log storage and avoid performance impacts.

Troubleshooting Automation with Debug Logs (Salesforce Advanced Administrator – Advanced Process Automation)

Why This Topic Matters
As an Advanced Administrator, you are expected to go beyond building automation; you must be able to diagnose it when it misbehaves. Flows fail silently, validation rules block saves unexpectedly, Apex triggers conflict with declarative logic, and record-triggered automation fires in an unexpected order. Debug logs are the primary tool Salesforce provides for seeing exactly what happened during a transaction. On the Advanced Administrator exam, the Advanced Process Automation domain regularly tests whether you know when to use debug logs, how to set them up correctly, what they contain, and how to interpret them alongside other troubleshooting tools such as Flow error emails, Flow debug mode, and the Setup Audit Trail.

What a Debug Log Is
A debug log is a detailed record of every event that occurs during a single Salesforce transaction executed by a specific user, including:
• Database operations (SOQL, SOSL, DML)
• Apex code execution and exceptions
• Workflow rules, Process Builder, and Flow execution (including element-by-element flow interviews)
• Validation rule evaluation
• Callouts, system resource usage, and governor limit consumption

Logs are generated only when a trace flag is active for the user (or Apex class/trigger, or Automated Process user). You set trace flags in Setup → Debug Logs, choosing a debug level and a start/expiration window (maximum 24 hours per trace flag).

How It Works
1. Set a Trace Flag
• Traced Entity Type: User (most common), Apex Class, Apex Trigger, or Automated Process (needed when automation runs as the Automated Process user, e.g., scheduled flows, platform events, some approval actions).
• Debug Level: a named set of log categories (Apex Code, Workflow, Validation, Database, System, Callout, etc.) each with a level: NONE, ERROR, WARN, INFO, DEBUG, FINE, FINER, FINEST. For flow troubleshooting, set Workflow to FINER or FINEST; for Apex, set Apex Code to FINEST. Higher levels produce more detail but hit the size cap faster.

2. Reproduce the Issue
Have the traced user perform the action (edit the record, submit the approval, run the flow). Each transaction creates one log.

3. Read the Log
Each line follows the pattern timestamp | EVENT_IDENTIFIER | details. Key events to recognize:
• FLOW_START_INTERVIEW / FLOW_ELEMENT_BEGIN / FLOW_ELEMENT_ERROR – shows the flow entered, which element ran, and where it failed.
• FLOW_ASSIGNMENT_DETAIL / FLOW_VALUE_ASSIGNMENT – shows variable values at each step.
• WF_RULE_EVAL_BEGIN / WF_CRITERIA_END – workflow rule criteria results.
• VALIDATION_RULE / VALIDATION_FAIL / VALIDATION_PASS – which validation rule blocked a save and the formula evaluated.
• CODE_UNIT_STARTED – marks the start of a trigger, class, or Workflow unit; useful for understanding order of execution.
• SOQL_EXECUTE_BEGIN / DML_BEGIN – database activity; count these to diagnose governor limit issues.
• EXCEPTION_THROWN / FATAL_ERROR – the actual error and stack trace.
• LIMIT_USAGE_FOR_NS – a summary of governor limits consumed (SOQL queries, DML statements, CPU time, heap).

4. Apply the Findings
Fix the flow element, adjust the validation rule, reorder or consolidate automation, or add fault paths and null checks.

Key Limits and Behaviors to Remember
• Each debug log is capped at 20 MB; if exceeded, Salesforce truncates it, so lower the debug level when logs are truncated.
• Org-wide storage limit is 1,000 MB of debug logs; once reached, new logs stop until old ones are deleted.
• A trace flag can be active for a maximum of 24 hours, after which it must be renewed.
• Logs are retained for 7 days (and may be deleted earlier if storage is reached).
• To debug flows that run in system context as the Automated Process user (scheduled flows, platform event-triggered flows), you must trace the Automated Process entity, not a normal user.
• Debug logs do not capture guest user or platform-level actions unless specifically traced.

Complementary Troubleshooting Tools (know when to pick each)
• Flow Debug Mode (Debug button in Flow Builder): step through a screen flow or autolaunched flow with chosen inputs; shows every element and variable without needing trace flags. Can run as another user and "Run flow in rollback mode." Best for building/testing; not useful for a failure that already happened in production.
• Flow Error Emails: when an autolaunched or record-triggered flow fails, Salesforce emails the admin (or the user who last modified the flow, depending on Process Automation Settings) with the element where it failed, the error, and the interview details. This is the fastest first clue.
• Paused and Failed Flow Interviews page: review flows awaiting a scheduled path or resume event.
• Setup Audit Trail: identifies who changed a flow, validation rule, or setting and when; use when the question is "what changed?" rather than "what happened?"
• Apex Exception Emails / Email Logs: for code-related or email delivery failures.
• Developer Console / Apex Replay Debugger: advanced log analysis with filters, but the certification focuses on Setup → Debug Logs.

Common Scenarios and Correct Responses
• A user reports a record save fails with an unclear error. → Set a trace flag on that user, have them reproduce, look for VALIDATION_FAIL, FLOW_ELEMENT_ERROR, or EXCEPTION_THROWN.
• A scheduled flow fails nightly but no user log appears. → Trace the Automated Process entity.
• Log is truncated at 20 MB. → Reduce debug level categories you do not need (e.g., set Database and System to NONE, keep Workflow at FINER).
• You want to see variable values inside a flow before deployment. → Use Flow Builder Debug Mode rather than debug logs.
• Record-triggered flow updates a field, then a workflow rule overwrites it. → Read CODE_UNIT_STARTED events to confirm the order of execution; consolidate automation into one flow.
• Too many SOQL queries error. → Count SOQL_EXECUTE_BEGIN lines inside a loop; move the Get Records element outside the loop.

Exam Tips: Answering Questions on Troubleshooting Automation with Debug Logs
1. Identify the "when" of the problem. If the failure already occurred for a specific user, the answer is a trace flag on that user plus reproduce. If the admin is still designing the flow, the answer is Flow Debug Mode. If the question asks who changed something, it is Setup Audit Trail.
2. Watch for "system context" or "scheduled" wording. That signals the Automated Process trace entity, a frequently missed distractor.
3. Remember the numbers: 20 MB per log, 1,000 MB org cap, 24-hour trace flag maximum, 7-day retention. Exam writers love numeric distractors (e.g., 2 MB, 48 hours).
4. Match the debug level to the problem. Flow/workflow issues → Workflow category at FINER/FINEST. Apex issues → Apex Code at FINEST. If the question mentions truncated logs, the fix is to lower levels on irrelevant categories, not to create more trace flags.
5. Know the event names at a recognition level. You will not be asked to write log lines, but you may be shown a snippet and asked what it means (e.g., FLOW_ELEMENT_ERROR means the flow failed at a specific element; VALIDATION_FAIL means a validation rule blocked the save).
6. Eliminate "create a new user / deactivate automation" answers. The exam prefers non-destructive diagnostic steps first: enable logging, reproduce, analyze, then fix.
7. Flow error emails are the first clue, debug logs are the deep dive. If a question offers both, choose the error email for "quickest way to identify the failing element" and debug logs for "detailed sequence of events in the transaction."
8. Order of execution questions often hide inside troubleshooting scenarios. Recall: before-save flows → validation rules → after-save flows/triggers → assignment/auto-response/workflow rules → escalation → roll-up summaries → post-commit (emails). Debug logs let you confirm this sequence.
9. Read the question for the persona. "Only one user is affected" → user-level trace flag. "All users running a specific trigger" → Apex Trigger trace flag.
10. Default to best practice. When a log reveals a loop with DML inside, the correct remediation is to move Get/Update Records outside the loop and use collections, not to request a limit increase.

Quick Review Checklist
• Trace flag → User, Apex Class, Apex Trigger, Automated Process
• Debug level categories and levels (NONE to FINEST)
• Reproduce → Read → Fix
• 20 MB / 1,000 MB / 24 hours / 7 days
• Flow Debug Mode for design-time, debug logs for run-time, Setup Audit Trail for "who changed it"
• Key events: FLOW_ELEMENT_ERROR, VALIDATION_FAIL, EXCEPTION_THROWN, CODE_UNIT_STARTED, LIMIT_USAGE_FOR_NS

Mastering these points lets you confidently answer any Advanced Administrator exam question about diagnosing broken automation with debug logs.
Test mode:

Admin II - Troubleshooting Automation with Debug Logs Example Questions

Test your knowledge of Troubleshooting Automation with Debug Logs

Question 1

At Northern Trail Outfitters, a record-triggered flow on Opportunity fails for one sales rep only now and then. The administrator set a user trace flag on the rep, and the rep reproduced the failure. The debug level has Apex Code, Database, and Validation at Finest. The resulting log is cut off and is missing the flow element lines needed to find the fault. What should the administrator do to capture the flow detail on the next attempt?

Question 2

At Ursa Major Solar, a record-triggered flow on Case has an immediate path and a scheduled path that updates the Case one day later. A support agent reports that the scheduled updates never happen. The administrator added an active trace flag on the agent with Workflow set to FINER. The new log shows the immediate path running, but no log ever appears for the scheduled path. What explains this, and what should the administrator do?

Question 3

In a Salesforce debug log, which log category records flow interview and flow element events, such as decisions and assignments, at the Finer or Finest level?

More Troubleshooting Automation with Debug Logs questions
30 questions (total)