Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full System Log entry
How-to guide

Capture a System Log to debug an Apex failure

Open the Developer Console, set the right log levels, reproduce the failing action, and read the resulting System Log to find the root cause.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated May 26, 2026

Open the Developer Console, set the right log levels, reproduce the failing action, and read the resulting System Log to find the root cause.

  1. Open the Developer Console

    Setup, Developer Console (or the gear icon, Developer Console). The console opens in a new window with several tabs at the bottom.

  2. Open the Logs panel

    Click the Logs tab at the bottom. The panel lists recent logs for your user, sorted descending by timestamp.

  3. Set log levels

    Debug, Change Log Levels. For most debugging, set Apex Code to FINEST, Apex Profiling to FINEST, Database to FINEST, and the rest to INFO. Save.

  4. Reproduce the failure

    Take the action that triggers the bug: save the record, run the report, click the Lightning button. The platform captures the log automatically and appends it to the Logs panel.

  5. Open the log

    Double-click the new log row. The System Log opens with the captured execution. Tabs at the top let you switch between Raw Log, Execution Tree, and Limits views.

  6. Read the LIMIT_USAGE_FOR_NS block

    Scroll to the bottom of the Raw Log. Find the LIMIT_USAGE_FOR_NS block. Note the dominant counter, then trace back to the line that drove it up. That line is your starting point for the fix.

Key options
Log Levelremember

Per-category setting (NONE through FINEST). Higher levels produce more detail but consume the 250 MB cap faster.

Trace Flagremember

Time-boxed log directive scoped to a user, class, or trigger. Expires automatically; renew if a longer investigation is needed.

Execution Treeremember

Hierarchical view of method calls with timing and limit usage per branch. Best view for performance work.

Tooling API ApexLogremember

Programmatic access to captured logs. Used for export to external observability tools.

Gotchas
  • The 250 MB per-user log cap rolls over silently. If you reproduce a bug at high log levels and then run other work, the original log can be overwritten before you save it.
  • Trace flags expire in 24 hours. A long investigation needs renewed flags or you stop capturing logs at the wrong moment.
  • System.debug calls left in production code cost CPU time and inflate logs. Remove them before deploying or wrap them in a logging utility that respects an org-level flag.
  • Log levels too high (FINEST everywhere) make the log unreadable and can themselves push the transaction over the 10-second CPU limit. Use FINEST only on the category you are investigating.

See the full System Log entry

System Log includes the definition, worked example, deep dive, related terms, and a quiz.