Files
95cdd1cf31 Collect WSLg logs and crash dumps in collect-wsl-logs.ps1 (#40913)
* Collect WSLg logs in collect-wsl-logs.ps1

Gather WSLg graphical/audio logs into a wslg/ folder of the log archive:
weston.log, pulseaudio.log, wlog.log, stderr.log and versions.txt from
/mnt/wslg, plus crash dumps from %TEMP%\wsl-crashes (and legacy
/mnt/wslg/dumps). Logs are copied inside WSL as the uid=0 user so binary
dumps are preserved and root-only logs like pulseaudio.log are readable.

Document WSLg log collection and analysis in CONTRIBUTING.md,
doc/docs/debugging.md, and a new .github/copilot/wslg-logs.md guide,
including references to the microsoft/wslg repository.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Pass WSLg dest path as sh argument to handle quotes safely

Addresses PR review: a destination path containing a single quote
(e.g. C:\Users\O'Connor\...) would break the single-quoted sh -c string.
Pass the path as $1 and reference it via "$1" inside the script instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address review: timeout, --system, and gate WSLg dumps behind -Dump

- Collect WSLg logs inside a background job with a 60s timeout so a
  wedged WSL service cannot hang log collection.
- Use wsl.exe --system to reach /mnt/wslg, which works even when the
  default distro is WSL1 or is not running, and runs as the wslg user
  that owns the logs (removes the id -nu 0 super-user detection).
- Only collect WSLg crash dumps (/mnt/wslg/dumps and %TEMP%\wsl-crashes)
  when -Dump is passed, since users may not expect dumps by default.

Docs updated accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Use --system --user root for WSLg log collection

Run the WSLg collection as root in the system distro so root-owned logs
are guaranteed readable, removing ambiguity about required privileges.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* collect-wsl-logs: address WSLg review feedback

- Trim wslpath output before the null/whitespace check
- Explain the sh -c arg0/\ idiom used to pass the destination safely
- Lower the WSLg collection timeout from 60s to 20s

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* collect-wsl-logs: use New-Item -Force for the wslg folder instead of mkdir -p

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-09 09:34:00 -07:00
..