Salesforce debug logs
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.
Before you start
Section titled “Before you start”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.
Trace the right user
Section titled “Trace the right user”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 Checks | User to trace |
|---|---|
| The record-page card | The user viewing the record |
| A screen Flow or a record-triggered Flow | The user who ran the Flow or saved the record |
| Apex code | The user whose transaction runs the code |
| A Queueable or Batch job | The user who submitted the job |
| A Scheduled job | The user who scheduled the job |
| A Platform Event trigger or Platform Event-triggered Flow | The Automated Process user, unless the trigger is configured to run as another user |
Capture a log
Section titled “Capture a log”- In Setup, enter
Debug Logsin Quick Find, and select Debug Logs. - 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.
- Choose a Debug Level whose Apex Code level is WARN or finer, such as INFO, so the
[RHC] ERRORand[RHC] WARNlines appear. Select New Debug Level if no existing level qualifies. Record Health Check writes noINFOlines, and itsDEBUGlines are turned off outside Apex tests, so a finer level adds only Salesforce’s own detail. - Reproduce the problem once and note the time.
- Open the log for that time from the Debug Logs list.
- 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.
Read the [RHC] lines
Section titled “Read the [RHC] lines”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=...| Part | Meaning |
|---|---|
ERROR or WARN | The level. Start with ERROR lines. |
| The code after the level | Where it happened, such as BATCH_ or SET_. |
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 pairs | Details of the event. |
| The final section | The 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 code | Meaning |
|---|---|
SET_ | Salesforce rejected a Record Health Check Set Run event. errorCount gives the number of errors. |
CHECK_ | Salesforce rejected a Record Health Check Result event. |
LOG_ | Salesforce rejected a Record Health Check Log event, often because the user lacks Record Health Check Error Log Publisher. |
LOG_ | Publishing Log events threw an exception; the line gives its type and message. |
FRAMEWORK_ | The Check Set has more than 25 active Checks. totalAvailable, maxPerRun, and omitted give the counts. |
DISPLAY_ | A Display: Found Formula or Display: Expected Formula could not be evaluated, so the card shows no value for it. |
Search the log
Section titled “Search the log”Search in this order:
- The Run ID, to find every line of the run.
[RHC] ERROR, then[RHC] WARN.EXCEPTION_THROWNandFATAL_ERROR, for exceptions Record Health Check did not catch.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.
Investigate async jobs
Section titled “Investigate async jobs”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:
- In Setup, open Apex Jobs, and find the job by its class, such as
RecordHealthCheckBatch, and its submission time. - Note the job ID, its status, the number of failed batches, and the user who submitted it.
- 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.
Keep errors after the log expires
Section titled “Keep errors after the log expires”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.
Remove sensitive data before sharing
Section titled “Remove sensitive data before sharing”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.