@samitouri / QOSAMI-WSL / commits / 6807291a

Add a powershell script to collect WSL logs, and reference it as the prefered method in CONTRIBUTING.MD (#8348)

* Add a powershell script to collect WSL logs, and reference it as the prefered method in CONTRIBUTING.MD

Blue committed May 3, 2022 at 14:20 UTC 6807291a64dc2074e79c8dab10ca0c2b447cd582
2 files changed +59 -20
CONTRIBUTING.md
+14 -20
@@ -132,7 +132,19 @@ Once the script execution is completed, include **both** its output and the gene
132 <div id="8-detailed-logs"></div>
133 <div id="9-networking-logs"></div>
134
135 -### 8) Collect WSL logs
135 +
136 +#### 8) Collect WSL logs (recommended method)
137 +
138 +To collect WSL logs, download and execute [collect-wsl-logs.ps1](https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1) in an administrative powershell prompt:
139 +
140 +```
141 +Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
142 +Set-ExecutionPolicy Bypass -Scope Process -Force
143 +.\collect-wsl-logs.ps1
144 +```
145 +The scipt will output the path of the log file once done.
146 +
147 +### 9) Collect WSL logs with Feedback hub
148 To collect WSL logs follow these steps:
149
150 #### Open Feedback Hub and enter the title and description of your issue
@@ -168,22 +180,4 @@ To collect WSL logs follow these steps:
180 - Hit Submit
181 - Get a link to your feedback item by clicking on 'Share my Feedback' and post that link to the Github thread so we can easily get to your feedback!
182
171 -![GIF Of networking instructions](img/networkinglog4.gif)
172 -
173 -#### Record WSL logs manually
174 -
175 -If creating a Feedback Hub entry isn't possible, then WSL logs need to be captured manually.
176 -
177 -To do so, first download [wsl.wprp](https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp), then run in an administrative command prompt:
178 -
179 -```
180 -$ wpr -start wsl.wprp -filemode
181 -```
182 -
183 -Once the log collection is started, reproduce the problem, and run:
184 -
185 -```
186 -$ wpr -stop wsl.etl
187 -```
188 -
189 -This will stop the log collection and create a file named `wsl.etl` that will capture diagnostics information.
183 +![GIF Of networking instructions](img/networkinglog4.gif)
\ No newline at end of file
diagnostics/collect-wsl-logs.ps1 new
+45
@@ -0,0 +1,45 @@
1 +#Requires -RunAsAdministrator
2 +
3 +[CmdletBinding()]
4 +Param (
5 + $LogProfile = $null
6 + )
7 +
8 +$ErrorActionPreference = "Stop"
9 +Set-StrictMode -Version Latest
10 +
11 +$folder = "WslLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")
12 +mkdir -p $folder
13 +
14 +if ($LogProfile -eq $null)
15 +{
16 + $LogProfile = "$folder/wsl.wprp"
17 + Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp" -OutFile $LogProfile
18 +}
19 +
20 +reg.exe export HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKCU.reg
21 +reg.exe export HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKLM.reg
22 +reg.exe export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\P9NP $folder/P9NP.reg
23 +
24 +$wslconfig = "$env:USERPROFILE/.wslconfig"
25 +if (Test-Path $wslconfig)
26 +{
27 + Copy-Item $wslconfig $folder
28 +}
29 +
30 +get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux > $folder/appxpackage.txt
31 +get-acl "C:\ProgramData\Microsoft\Windows\WindowsApps" | Format-List > $folder/acl.txt
32 +
33 +wpr.exe -start $LogProfile -filemode
34 +
35 +Write-Host -NoNewLine -ForegroundColor Green "Log collection is running. Please reproduce the problem and press any key to save the logs."
36 +$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
37 +
38 +Write-Host "`nSaving logs..."
39 +
40 +wpr.exe -stop $folder/logs.etl
41 +$logArchive = "$(Resolve-Path $folder).zip"
42 +Compress-Archive -Path $folder -DestinationPath $logArchive
43 +Remove-Item $folder -Recurse
44 +
45 +Write-Host -ForegroundColor Green "Logs saved in: $logArchive. Please attach that file to the GitHub issue."
\ No newline at end of file