grzmol/vibe-force/sf-debugging-logs
Claude Code and agent skill by grzmol/vibe-force
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Salesforce debug logging and diagnostics - trace flags and debug levels via TraceFlag and DebugLevel Tooling API objects or sf data create record --use-tooling-api, log categories and levels, the 20 MB log and 1000 MB trace-flag limits, sf apex list log, sf apex get log, sf apex tail log and sf apex run for anonymous Apex, reading execution units, CODE_UNIT_STARTED, SOQL_EXECUTE_BEGIN/END, DML_BEGIN, LIMIT_USAGE_FOR_NS, CUMULATIVE_PROFILING and FLOW_* lines, diagnosing CPU time and heap, Apex Replay Debugger with checkpoints and heap dumps, Developer Console Log Inspector and Query Plan, AsyncApexJob and batch/queueable failures, Flow debugging, LWC browser debugging, callout and Named Credential errors, and safe production diagnostics with Event Monitoring. Use when a test or transaction fails, a limit is exceeded, an async job silently fails, or when running vf-check smoke, vf-check apex, or vf-check verify.
Install
npx vskill@latest install grzmol/vibe-force/sf-debugging-logsSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as grzmol/vibe-force/sf-debugging-logs.
Debugging and Debug Logs
When to use
- An Apex test, trigger, batch, queueable, Flow, or LWC action fails and the error message is not
sufficient.
- A governor limit is hit (
Apex CPU time limit exceeded,Apex heap size too large, too many SOQL
queries) and you need the transaction's actual consumption.
- An async job reports failure with no stack trace.
- A callout fails and you need the request/response.
- Post-deploy verification fails in a real org and diagnostics must be captured into
.vibeforce/reports/.
Pipeline
Limits that bite
| Limit | Value | Consequence | |
|---|---|---|---|
| Single debug log size | 20 MB | larger logs are reduced by removing older log lines, from anywhere in the log, not just the start; a truncated log silently loses System.debug output | |
| System log retention | 24 hours | Location = SystemLog, visible only to you | |
| Monitoring log retention | 7 days | Location = Monitoring, visible to all administrators | |
| Log generation rate | 1000 MB per 15-minute window | trace flags are disabled automatically and an email is sent to the last user who modified them; re-enable after 15 minutes | |
| Org log accumulation | 1000 MB | users can no longer add or edit trace flags until debug logs are deleted | |
| Trace flag duration | ExpirationDate must be less than 24 hours after StartDate | expired flags stop logging | |
| Active trace flags | one per traced entity | a second flag for the same user or class conflicts |
A trace flag on a frequently executed class or a busy user can make requests fail outright, regardless of the window and log sizes. Scope trace flags to one user, one short window.
Order of precedence for log levels
- Active trace flags override everything. The Developer Console sets a
DEVELOPER_LOGtrace flag
when it loads, which stays in effect until it expires.
- With no active trace flags, synchronous and asynchronous Apex tests run at the default levels:
DB=INFO, APEX_CODE=DEBUG, APEX_PROFILING=INFO, WORKFLOW=INFO, VALIDATION=INFO, CALLOUT=INFO, VISUALFORCE=INFO, SYSTEM=DEBUG.
- With no relevant trace flags and no tests running, the API request's debugging header sets the
levels. Requests without a debugging header produce transient (unsaved) logs.
- If the entry point sets a level (a Visualforce debugging parameter, for example), that wins.
- Otherwise no log is generated or persisted.
Class and trigger trace flags (LogType = CLASS_TRACING) override other levels, including user trace flag levels, but they do not themselves cause logging to happen.
Core patterns
1. Tail a live org while reproducing
2. List and fetch logs
--number fetches the N most recent logs; --output-dir writes them as files instead of printing.
3. Run anonymous Apex and read its log
Anonymous Apex always runs with sharing. Its log appears under CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex. Use LoggingLevel.ERROR for probe output so the line survives a low APEX_CODE level, and prefix a grep-able token (VF_PROBE).
4. Set a trace flag deterministically from the CLI
LogType values: USER_DEBUG (trace one user), CLASS_TRACING (override levels for one Apex class or trigger; does not itself generate logs), DEVELOPER_LOG (what the Developer Console sets), PROFILING (reserved for future use). Field-by-field reference: references/debug-log-reference.md.
5. Read a log in the right order
For a failing transaction, read bottom-up then top-down:
| Step | Look for | Tells you | |
|---|---|---|---|
| 1 | FATAL_ERROR | exception type, message, stack trace | |
| 2 | CUMULATIVE_LIMIT_USAGE / LIMIT_USAGE_FOR_NS | which limit was near or over | |
| 3 | EXECUTION_STARTED ... EXECUTION_FINISHED | transaction boundary | |
| 4 | CODE_UNIT_STARTED / CODE_UNIT_FINISHED nesting | which trigger, Flow, batch chunk, or async entry point ran, and in what order | |
| 5 | SOQL_EXECUTE_BEGIN / SOQL_EXECUTE_END | query text, row counts, duration | |
| 6 | DML_BEGIN / DML_END | operation, object, row count | |
| 7 | CUMULATIVE_PROFILING | expensive queries and DML aggregated for the transaction | |
| 8 | FLOW_ELEMENT_*, FLOW_ELEMENT_ERROR, FLOW_ELEMENT_FAULT | declarative automation in the same transaction |
Log line format is timestamp|event identifier|..., pipe-delimited. The timestamp's parenthesised value is nanoseconds elapsed since the start of the request, which is how you find the slow section. The Developer Console Execution Log view hides elapsed time; open the Raw Log view to see it. [EXTERNAL] replaces a line number for built-in Apex or managed-package code. Trigger code units carry a typeRef of __sfdc_trigger/YourTrigger or __sfdc_trigger/YourNamespace/YourTrigger.
Symptom-driven recipes with real log excerpts: references/log-analysis-playbook.md.
6. Diagnose CPU time and heap
- CPU time: subtract the elapsed nanoseconds between the
CODE_UNIT_STARTEDand
CODE_UNIT_FINISHED of each unit to find which unit consumes it. CUMULATIVE_PROFILING names the expensive queries. Callout wait time does not count toward CPU time; loops, collection work, describes, and JSON serialization do.
- Heap: heap usage is reported accurately in the log and an exception is thrown when an Apex heap
size error occurs. At other times the reported heap size is the largest calculated during the transaction, and minimal usage is reported as 0 to reduce overhead on small transactions. Set APEX_CODE to FINER or higher to see HEAP_ALLOCATE lines with byte counts per line number.
- Limit remediation itself: skill
sf-governor-limits; query tuning: skill
sf-soql-sosl-optimization.
7. Async job debugging
JobType values: ApexToken, BatchApex, BatchApexWorker, Future, Queueable, ScheduledApex, SharingRecalculation, TestRequest, TestWorker. Status values: Aborted, Completed, Failed, Holding (flex queue), Preparing, Processing, Queued. ExtendedStatus holds a short description of the first error only; the rest is emailed to the last user who modified the batch class. NumberOfErrors counts failed batches, not failed records - a batch is transactional, so one unhandled exception fails the whole chunk. Chunked batch jobs create BatchApexWorker children carrying ParentJobId.
Each async execution is a separate transaction and produces its own debug log, so a batch with 50 chunks produces up to 50 logs. Attach a Finalizer to a Queueable so failures are observable even when the job dies (skill sf-async-apex-patterns).
8. Replay debugging
Or, for a test or anonymous Apex file, SFDX: Launch Apex Replay Debugger with Current File directly: it updates checkpoints, sets and then deletes trace flags, and generates a fresh log. Checkpoints expire after 30 minutes and heap dumps after about a day; only one log can be replayed at a time, which makes async debugging awkward. Full capability and limitation list: references/debugging-tools.md.
9. Flow and declarative automation
Flow execution appears in the same transaction log under FLOW_* events at the Workflow category. FLOW_ELEMENT_BEGIN / FLOW_ELEMENT_END bracket each element, FLOW_VALUE_ASSIGNMENT shows variable writes, FLOW_BULK_ELEMENT_LIMIT_USAGE and FLOW_ELEMENT_LIMIT_USAGE show the limits a Flow consumed inside your transaction, and FLOW_ELEMENT_ERROR / FLOW_ELEMENT_FAULT mark failures and fault-path transitions. When an Apex trigger appears to burn queries it did not issue, look for interleaved FLOW_* units. Flow design: skill sf-flow-automation.
10. Client-side (LWC) debugging
- Enable Debug Mode for the specific user in Setup so the framework ships unminified code with
source maps; keep it off for everyone else because it slows the app.
- Use browser devtools: breakpoints in the component's
.js, the Network tab for
aura / apex XHRs, and the Lightning Component Inspector for component trees and wire state.
- Wire errors surface in the
errormember of the wire result, not in a debug log; log them in the
component during development, never in shipped code.
consolepolicy:console.erroris permitted for genuine failures; otherconsolecalls are
ESLint errors outside __tests__ (skill sf-code-analyzer-quality).
- Server-side behaviour of an
@AuraEnabledcall is still diagnosed with a debug log on the calling
user; the code unit name identifies the Apex method.
Anti-patterns
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/sf-debugging-logs/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/grzmol/vibe-force/sf-debugging-logs)