Skip to content
Suggest a correction

Salesforce debug logs

Guide5 min read

Capture a Salesforce debug log to investigate a Record Health Check problem that the card’s diagnosis cannot explain, such as a failing Flow, Apex call, or async job, or an error that stops the whole transaction. Record Health Check writes one line, starting with [RHC], for each event it logs, so a debug log shows what it did and where it stopped.

For a problem on the record-page card, start with Troubleshoot with Show Diagnostics: the card’s diagnosis and console report usually explain the problem without a debug log.

Record these values, so you can find the right log:

  • the exact time of the problem and its time zone;
  • the user who ran the Checks;
  • what started the run: the card, a Flow, Apex, or a Queueable, Batch, or Scheduled job;
  • the Check Set and Check Qualified API Names; and
  • the Run ID, when the card’s console report or a Platform Event shows it.

A debug log records only the transactions of the user it traces. Trace the user who runs the Checks, which is not always the user who started the work:

What runs the ChecksUser to trace
The record-page cardThe user viewing the record
A screen Flow or a record-triggered FlowThe user who ran the Flow or saved the record
Apex codeThe user whose transaction runs the code
A Queueable or Batch jobThe user who submitted the job
A Scheduled jobThe user who scheduled the job
A Platform Event trigger or Platform Event-triggered FlowThe Automated Process user, unless the trigger is configured to run as another user
  1. In Setup, enter Debug Logs in Quick Find, and select Debug Logs.
  2. Under User Trace Flags, select New. Choose the Traced Entity Type and the user from Trace the right user, and set a short expiration, such as one hour.
  3. Choose a Debug Level whose Apex Code level is WARN or finer, such as INFO, so the [RHC] ERROR and [RHC] WARN lines appear. Select New Debug Level if no existing level qualifies. Record Health Check writes no INFO lines, and its DEBUG lines are turned off outside Apex tests, so a finer level adds only Salesforce’s own detail.
  4. Reproduce the problem once and note the time.
  5. Open the log for that time from the Debug Logs list.
  6. Delete the trace flag when you are finished.

Salesforce deletes debug logs after a short time and limits their size. When a log is truncated, reproduce the problem with a single record.

Each line has this shape:

[RHC] ERROR BATCH_SCOPE_FAILED | runId=batch-7071x00000AbCdEFGH user=005000000000001AAA checkSet=Account_Data_Quality | System.DmlException: Insert failed. UNABLE_TO_LOCK_ROW stack=...
PartMeaning
ERROR or WARNThe level. Start with ERROR lines.
The code after the levelWhere it happened, such as BATCH_SCOPE_FAILED or SET_RUN_PUBLISH_FAILED.
runId=The Run ID. Every line from one run has the same value.
user=The user who ran the Checks.
checkSet=, check=, record=The Check Set, Check, and record, when known.
Other name=value pairsDetails of the event.
The final sectionThe exception type, its message, and the stack trace, when an exception occurred.

The Log event codes table explains the ERROR codes. A WARN line reports a problem that did not change any Check result:

WARN codeMeaning
SET_RUN_PUBLISH_FAILEDSalesforce rejected a Record Health Check Set Run event. errorCount gives the number of errors.
CHECK_RESULT_PUBLISH_FAILEDSalesforce rejected a Record Health Check Result event.
LOG_EVENT_PUBLISH_FAILEDSalesforce rejected a Record Health Check Log event, often because the user lacks Record Health Check Error Log Publisher.
LOG_EVENT_FLUSH_FAILEDPublishing Log events threw an exception; the line gives its type and message.
FRAMEWORK_MAX_CHECKS_EXCEEDEDThe Check Set has more than 25 active Checks. totalAvailable, maxPerRun, and omitted give the counts.
DISPLAY_FORMULA_INVALIDA Display: Found Formula or Display: Expected Formula could not be evaluated, so the card shows no value for it.

Search in this order:

  1. The Run ID, to find every line of the run.
  2. [RHC] ERROR, then [RHC] WARN.
  3. EXCEPTION_THROWN and FATAL_ERROR, for exceptions Record Health Check did not catch.
  4. LIMIT_USAGE_FOR_NS, for the governor limits the transaction used.

Fix the first error in the transaction. Later errors are often caused by the first one.

When the log shows FATAL_ERROR with System.LimitException, the transaction exceeded a Salesforce governor limit, which Apex cannot catch. Reduce the records per request or the Checks per Check Set; see Platform limitations.

A Queueable, Batch, or Scheduled job runs in its own transactions, separate from the code that submitted it. Find the job before you look for its log:

  1. In Setup, open Apex Jobs, and find the job by its class, such as RecordHealthCheckBatch, and its submission time.
  2. Note the job ID, its status, the number of failed batches, and the user who submitted it.
  3. Trace that user and run the job again.

Events from a Batch job carry the Run ID batch- followed by the job ID, and events from a Queueable job carry queue- followed by the job ID. A job that completed in Apex Jobs can still contain Checks that failed; the job status does not report health-check results.

See Asynchronous Apex for each job’s behavior.

Debug logs are short-lived. To keep a lasting record of Record Health Check errors, select Publish Error Log Event on the Check Set and save the Record Health Check Log Platform Event. It carries the same message, exception type, and stack trace as the [RHC] ERROR line.

Before you share a log, remove customer data, record IDs, user IDs, org IDs, session IDs, access tokens, and queries that contain sensitive values. Keep the Run ID, the error code, the exception type, and the first stack trace line of the error.