Sub topic 6
Step debug logs and runner diagnostic logs
This chapter assumes you can read a workflow file and open a job log in the Actions tab. It also assumes you know that a failed run can be re-run. It covers the two kinds of extra logging GitHub Actions offers when a normal log doesn't explain a failure. Later chapters cover how to turn each one on.
Why a normal log is sometimes not enough
A normal job log shows each step's command and its output. It does not show why the runner made a decision, such as how it resolved an action, how it evaluated a condition, or how it set up the job. When a step fails with a vague message, or behaves differently on the runner than on your machine, you need more detail.
GitHub provides two separate switches for this. They produce different output in different places, so it helps to treat them as two tools.
Step debug logs
Step debug logging adds extra lines to the job log. These come from the runner and from the actions your steps use. You see them in the same log view you already use.
- Debug lines are prefixed with
##[debug]and shown in a distinct color. - They include extra detail about how steps were set up and evaluated.
- Any
::debug::message written by your own steps appears only when this mode is on. Without it, those messages are discarded.
The persistent switch is a secret or variable named ACTIONS_STEP_DEBUG with the value true. If both a secret and a variable exist with that name, the secret takes precedence.
Runner diagnostic logs
Runner diagnostic logging is a different feature. It records the runner application's own internal log files. These are the Runner_*.log and Worker_*.log files in the runner's _diag folder.
- They are not shown in the web log view.
- You get them by downloading the log archive for the run. Diagnostic files are included in the archive when this mode is on.
- On a self-hosted runner, the same files also sit in the
_diagfolder on the machine.
The persistent switch is a secret or variable named ACTIONS_RUNNER_DEBUG with the value true.
Use these logs when the problem is the runner itself. Examples are a job that fails to start, a step that is cancelled for no visible reason, or a network error during setup.
Comparing the two
| Row | Step debug logs | Runner diagnostic logs |
|---|---|---|
| Switch | `ACTIONS_STEP_DEBUG` | `ACTIONS_RUNNER_DEBUG` |
| Content | Extra lines about steps and actions, plus your `::debug::` messages | Internal runner and worker log files |
| Where to read | Job log in the web interface | Downloaded log archive, or `_diag` on self-hosted runners |
| Best for | A step behaves unexpectedly | The runner or job setup misbehaves |
Two ways to turn them on
You can enable debug logging in two ways, and each has a different reach.
- For one re-run. When you re-run a run, you can ask for debug logging for that attempt only. This enables both log types for that attempt, and nothing is stored in the repository settings.
- For every run. You create the
ACTIONS_STEP_DEBUGandACTIONS_RUNNER_DEBUGvalues yourself as secrets or variables. They then apply to all future runs until you delete them.
Prefer the first when you are investigating one failure. The second is for problems that are intermittent or that you can't reproduce on demand.
Seeing the difference in a workflow
This workflow prints one ::debug:: message and then runs a diagnostics step only when debug logging is on. The runner.debug context value is 1 in that case. It is covered in detail in a later chapter.
name: debug-demo
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Emit a debug message
run: echo "::debug::Visible only with step debug logging"
- name: Diagnostics when debug is on
if: ${{ runner.debug == '1' }}
run: env | sort | grep '^RUNNER_'Run it normally and the first step prints nothing visible. Re-run it with debug logging and the message appears with the ##[debug] prefix. The second step runs too.
Exercise
A job fails during setup, before any of your steps run, and the web log shows only a short error. Which debug type is more likely to help, and where do you read its output?
Show answer
Runner diagnostic logging. Its Runner and Worker log files cover runner internals such as job setup. You read them in the downloaded log archive, or in the _diag folder on a self-hosted runner. Step debug lines would also help, but they come from the steps and actions rather than from the runner's own setup.