-
Notifications
You must be signed in to change notification settings - Fork 677
Enabling C# debugger logging
Here is how to enable additional logging for the VS Code C# debugger to help troubleshoot problems.
The quick way to enable logging is to modify your .vscode/launch.json file and add a new 'logging' entry into your active configuration. This works in all cases except problems that happen very early in the initialization stage of the debugger. Here is an example of the new sections to add to launch.json:
"configurations": [
{
"...": "...",
"logging": {
"traceResponse": true,
"engineLogging": true
}
},
{ "...": "..." }
]
When this is enabled, logging will be sent to the VS Code Debug Console where you can copy/paste the relevant sections.
If you are dealing with a problem that happens either very early on during debugger startup, or you want to gather complete logs, it is also possible to send logging output to a file. Though this method requires a bit more work. Here are the steps.
Fire up your favorite editor and open the C# extension's package.json file. You might want to use something other than VS Code so that you can restart VS Code without having to close this file, but it isn't required. The package.json can be found here:
- Windows: C:\Users\<your-username>\.vscode\extensions\ms-vscode.csharp-<ver>\package.json
- OSX/Linux: ~/.vscode/extensions/ms-vscode.csharp-<ver>/package.json
NOTE: If you are using the Insiders build of VS Code, replace '.vscode' with '.vscode-insiders'.
We want to find the 'contributes.debuggers[0].<os-name>.program' element in package.json. The fastest way to do this is to search for '.debugger/vsdbg-ui'. You should see something like this:
"windows": {
"program": "./.debugger/vsdbg-ui.exe"
},
"osx": {
"program": "./.debugger/vsdbg-ui"
},
"linux": {
"program": "./.debugger/vsdbg-ui"
}
Add a new property after program to pass command line arguments to vsdbg-ui. We want to pass '--engineLogging' which will save a log to $HOME/vsdbg-ui.log (or %HOMEDRIVE%%HOMEPATH%\vsdbg-ui.log on Windows).
"osx": {
"program": "./debugger/vsdbg-ui",
"args": [ "--engineLogging" ]
}
Restart VS Code to make sure that VS Code re-reads package.json. Then start debugging as normal. Debug until the problem is hit, then stop debugging. You should now see that the log file has been written.
Put back package.json as it was before (no logging).
Configuration
- Configuring Snap installs of dotnet-sdk
- Configuring Arch Linux for Unity development
- Configuring Arch Linux for Razor development
- Installing the .NET Core Debugger on Arch Linux
Debugger
- Overview
- launch.json Help
- Feature List
- Enable Logging
- Portable PDBs
- Troubleshoot Breakpoints
- Attaching to remote processes
- Remote Debugging On Linux-Arm
- Windows Subsystem for Linux
- Diagnosting 'Debug adapter process has terminated unexpectedly'
- Testing libicu compatibility on Linux
- Debugging into the .NET Runtime itself
- Debugging x64 processes on an arm64 computer
Documentation
- Change Log
- Branches and Releases
- Installing Beta Releases
- Installing without internet connectivity
- Linux Support
- Run/Debug Unit Tests
- Troubleshooting: 'The .NET Core SDK cannot be located.' errors
Developer Guide