Sub topic 8
Turning on debug logging for every run
This chapter assumes you know how to re-run a job and how to read a run's logs in the Actions tab. It also assumes you know the difference between step debug logs and runner diagnostic logs from the previous chapter. You should be comfortable with gh commands and repository settings.
When a persistent setting makes sense
Debug logging for a single re-run is the safer default. It affects one attempt and then disappears. A persistent setting fits different cases:
- A failure that only happens on a trigger you can't re-run easily, such as a schedule or a
workflow_dispatchinput. - A flaky failure where you need verbose logs from the next run that fails, not from a re-run that may pass.
- A new workflow you are still building.
The two switches
Two names control persistent debug logging. Each can be set as a secret or as a variable.
| Name | Value | Effect |
|---|---|---|
| `ACTIONS_STEP_DEBUG` | `true` | Step debug logging. `::debug::` messages and extra step detail appear in the run log. |
| `ACTIONS_RUNNER_DEBUG` | `true` | Runner diagnostic logging. Extra runner log files are added to the downloadable log archive. |
Setting either one to true is enough. The value must be true. A missing entry means debug logging stays off.
Setting them with the gh CLI
Run these commands inside the repository you want to change. They affect all future runs there.
gh secret set ACTIONS_STEP_DEBUG --body true
gh variable set ACTIONS_RUNNER_DEBUG --body trueThe first command stores a secret. The second stores a variable. Either type works for either name, so you can pick whichever your team prefers. Variables are visible in the settings page, which makes it easy to see that debug logging is on. Secrets hide their value.
You can also use the web interface. Go to Settings, then Secrets and variables, then Actions. Add the name under the Secrets tab or the Variables tab.
To turn debug logging off, delete the entries:
gh secret delete ACTIONS_STEP_DEBUG
gh variable delete ACTIONS_RUNNER_DEBUGPrecedence and scope
You can define these names at the repository, environment, or organization level. Several definitions can exist at once, so check all levels when debug output appears and you can't find where it was enabled.
If the same name exists as both a secret and a variable, the secret takes precedence. Deleting only the variable can therefore leave debug logging on.
Checking that it worked
Start a run, open the job log, and look for these signs:
- With step debug logging on, extra lines marked
##[debug]appear in the step output. - With runner diagnostic logging on, the downloaded log archive gains runner diagnostic files.
- A step with
if: ${{ runner.debug == '1' }}now runs. This is the diagnostics step from the earlier workflow example.
If none of these appear, check the spelling of the name, since it is case-sensitive. Also confirm the value is exactly true. Then check that you set it in the repository where the workflow runs, not in a fork or a different repository.
Costs of leaving it on
Persistent debug logging applies to every run, so its downsides apply to every run too.
- Noise. Logs become much longer, and the line you need is harder to find.
- Exposure. Debug output can print environment details, command arguments, and paths that normal logs omit. Anyone who can read the run logs can read them.
- Forgotten settings. A setting added during an incident often stays for months.
Treat the setting as temporary. Add a reminder, such as an issue, when you turn it on. Delete the entries once you have the logs you need.
Exercise
A teammate deleted the repository variable ACTIONSSTEPDEBUG, but new runs still show ##[debug] lines. Give two likely causes and one command to check the first.
Show answer
First, a secret with the same name may still exist, and a secret takes precedence over a variable. Check with gh secret list. Second, the name may also be defined at the environment or organization level, so check those settings too.