I am trying to write a message to the output window for debugging purposes. I searched for a function like Java\'s system.out.println(\"\")
. I tried Debug
The call
System.Diagnostics.Debug.WriteLine("message");
fails when working with .NET Core (V 1.0 or 1.1).
We are supposed to create and use a logger from Microsoft.Extensions.Logging
, but that log only appears in the dotnet.exe popup console window, not in Visual Studio's Output window.
Use:
System.Diagnostics.Debug.WriteLine("your message here");
Debug.WriteLine
is what you're looking for.
If not, try doing this:
Menu Tools → Options → Debugging → uncheck Send Output to Immediate.
For debugging purposes, the System.Diagnostics.Debug.WriteLine()
command will not be compiled into the release version of your code unless you have debug listeners. It writes to all trace listeners which includes the VS output window when running in Debug mode.
For a Console application. Console.WriteLine()
would work but the output would still be generated in the release version of your binary.
Debug output should also appear in the normal output window when debugging tests; whereas, console.writeline output does not (but can be found in the test output window.)
Debug.Print("text here")
or
Console.WriteLine("text here")
This will write to the debug output window:
using System.Diagnostics;
Debug.WriteLine("Send to debug output.");