To see the debug output window, in Microsoft Visual Studio, click View, click Other Windows, and then click Output. You can view the debug output in this window only if the debugger is attached to the process that is writing to the output window.
WriteLine(String) Writes a message followed by a line terminator to the trace listeners in the Listeners collection. WriteLine(Object) Writes the value of the object's ToString() method to the trace listeners in the Listeners collection.
It goes to the console (standard output) or to the stream that the console is set to.
NET Framework Class Library namespace System.
While debugging System.Diagnostics.Debug.WriteLine
will display in the output window (Ctrl+Alt+O), you can also add a TraceListener
to the Debug.Listeners
collection to specify Debug.WriteLine
calls to output in other locations.
Note: Debug.WriteLine
calls may not display in the output window if you have the Visual Studio option "Redirect all Output Window text to the Immediate Window" checked under the menu Tools → Options → Debugging → General. To display "Tools → Options → Debugging", check the box next to "Tools → Options → Show All Settings".
As others have pointed out, listeners have to be registered in order to read these streams. Also note that Debug.Write
will only function if the DEBUG
build flag is set, while Trace.Write
will only function if the TRACE
build flag is set.
Setting the DEBUG
and/or TRACE
flags is easily done in the project properties in Visual Studio or by supplying the following arguments to csc.exe
/define:DEBUG;TRACE
You need to add a TraceListener
to see them appear on the Console.
TextWriterTraceListener writer = new TextWriterTraceListener(System.Console.Out);
Debug.Listeners.Add(writer);
They also appear in the Visual Studio Output window when in Debug mode.
While you are debugging in Visual Studio, display the "Output" window (View->Output). It will show there.
The Diagnostics messages are displayed in the Output Window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With