-
Notifications
You must be signed in to change notification settings - Fork 675
Enabling C# debugger logging
Here is how to enable additional logging for the VS Code C# debugger to help troubleshoot problems.
The C# debugger exposes several logging setting via a Visual Studio Code Setting. To modify them:
- Open up the VS Code settings editor (File->Preferences->Settings).
- Enter 'diagnosticsLog' into the search bar
- Navigate to 'Extensions->C#->Debugger' using the settings tree
- Enable the required setting. The most commonly used logging setting is 'Protocol Messages'.
When this is enabled, logging will be sent to the VS Code Debug Console where you can copy/paste the relevant sections.
If you have VS Code configured using a launch.json file with "type": "coreclr"
or "type": "clr"
, then you can configure logging using launch configuration properties. Here is an example of the new sections to add to launch.json:
"configurations": [
{
"type": "coreclr",
"...": "...",
"logging": {
"diagnosticsLog": {
"protocolMessages": true
}
}
},
{ "...": "..." }
]
Just like when configured via a VS Code Setting, 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 a problem where the debugger is crashing, it can be helpful to run the debugger (vsdbg-ui) in the console.
To do this:
- Open up a terminal (command prompt) window
- Change to the directory of the debugger. (NOTE: if you are using VS Code Insiders, change
.vscode
to.vscode-insiders
)-
Linux:
cd ~/.vscode/extensions/ms-dotnettools.csharp-<insert-version-here>-<insert-platform-here>/.debugger
-
macOS:
cd ~/.vscode/extensions/ms-dotnettools.csharp-<insert-version-here>-<insert-platform-here>/.debugger/<x86_64|arm64>
-
Windows:
cd /d C:\Users\<your-username>\.vscode\extensions\ms-dotnettools.csharp-<insert-version-here>-<insert-platform-here>\.debugger\<x86_64|arm64>
-
Linux:
- Run vsdbg-ui:
./vsdbg-ui --server --consoleLogging
- Go back to VS Code and open your
.vscode\launch.json
file. - Go to the section for of launch.json for your current launch configuration and add:
"debugServer": 4711
- Debug as normal
- When the problem happens, look at what is printed into the terminal.
Example launch.json configuration:
{
"version": "0.2.0",
"configurations": [
{
"debugServer": 4711,
"name": ".NET Core Launch (console)",
"...": "...",
},
{ "...": "..." }
]
}
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