Sub topic 7
Turning on debug logging for one re-run
This chapter assumes you can re-run all jobs, failed jobs, or a single job from the Actions tab or the gh CLI. It also assumes you know that each re-run creates a new run attempt. Here you will add debug logging to one of those re-runs, without changing repository settings.
Why enable debug logging for one re-run
A failed job often gives too little detail in its normal log. Debug logging adds more detail, but it also makes logs long and can expose more data. A re-run with debug logging avoids both problems. Only the new attempt gets the extra output, and later runs stay quiet.
Enabling debug logging for a re-run turns on two log types for that attempt:
- Step debug logging adds
##[debug]lines to the step output. These come from actions and from::debug::messages in your own steps. - Runner diagnostic logging adds log files from the runner application and the worker process.
Both are covered in the previous chapter. This chapter covers only how to switch them on for a single attempt.
From the web interface
- Open the failed run in the Actions tab.
- Choose Re-run all jobs, Re-run failed jobs, or Re-run this job on a single job.
- In the confirmation dialog, tick Enable debug logging.
- Click Re-run jobs.
The dialog appears for every re-run scope, so you can combine debug logging with any of them. The attempt selector at the top of the run page now shows the new attempt. Open it and look for lines starting with ##[debug].
From the gh CLI
Add --debug to any gh run rerun command:
gh run rerun 1234567890 --failed --debugThis re-runs only the failed jobs of run 1234567890, with debug logging on. To target one job, use the job ID instead of the run ID:
gh run rerun --job 987654321 --debugYou can find job IDs with gh run view 1234567890 --json jobs. Replace the example IDs with your own.
From the REST API
The "re-run failed jobs" endpoint takes a body parameter named enable_debug_logging:
gh api --method POST repos/OWNER/REPO/actions/runs/1234567890/rerun-failed-jobs -F enable_debug_logging=trueThe endpoints for re-running all jobs and for re-running a single job accept the same parameter. The -F flag sends true as a boolean. With -f it would be sent as the string "true", which is the wrong type for this field.
What you get, and where it appears
After the debug re-run finishes, look in two places.
| Log type | Where to find it |
|---|---|
| Step debug | In the job page, inside each step's log, as `##[debug]` lines. |
| Runner diagnostic | Only in the downloaded log archive, in a diagnostic logs folder for each job. |
Runner diagnostic files do not show up in the web log viewer. If you want them, use the Download log archive option in the run's gear menu. The next chapters cover reading and downloading logs in more detail.
Common errors
- Looking at the wrong attempt. The run page defaults to the latest attempt, but a link or a bookmark may point at attempt 1. Check the attempt selector before concluding that debug output is missing.
- Expecting debug output from a repeat re-run. The setting belongs to the attempt you started. If you re-run again without ticking the box, that attempt has normal logs.
- Re-running a run that is too old. GitHub limits how long a run can be re-run, so the buttons may be missing on old runs. In that case push a new commit and use the persistent settings from the next chapter.
- Wrong scope for the failure. If the failure depends on an earlier job's output, re-running only a single job may reuse artifacts from the original attempt. Re-run failed jobs, or all jobs, if you suspect the earlier job.
- Forgetting that a re-run uses the same commit. If you want to test a fix, you need a new run. A re-run always executes the original commit and workflow file.
Exercise
A job failed in run 555 with an unclear error. You want to re-run only the failed jobs with debug logging, then find the runner diagnostic logs. Which command do you use, and where do you find the diagnostic logs afterward?
Show answer
Run gh run rerun 555 --failed --debug. Step debug lines appear in the web log viewer, but the runner diagnostic logs appear only in the downloaded log archive for the new attempt.
Exercise
You call the REST API with -f enable_debug_logging=true and debug logging does not turn on. What is the likely cause, and what is the fix?
Show answer
The -f flag sends the value as a string instead of a boolean. Use -F enable_debug_logging=true so gh api sends a boolean.