Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does .NET's Debug.Write() output to?

Tags:

.net

I didn't see any output in the console or Visual Studio's output panel from:

Debug.Write("WriteStatements() was reached")

Where does the output go to?

like image 636
Ricky Avatar asked Mar 26 '10 09:03

Ricky


People also ask

Where does debug write go?

Debug. WriteLine will display in the output window ( Ctrl + Alt + O ), you can also add a TraceListener to the Debug.

Where does trace WriteLine write to?

WriteLine(String) Writes a message to the trace listeners in the Listeners collection.

How can I see debug output?

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.

How do I write to the Output window in Visual Studio?

You can write run-time messages to the Output window using the Debug class or the Trace class, which are part of the System. Diagnostics class library. Use the Debug class if you only want output in the Debug version of your program. Use the Trace class if you want output in both the Debug and Release versions.


1 Answers

Zhaph's answer already told you a way to get to the output of Debug.Write.

Under the hood, the default listener for Debug.Write, i.e. System.Diagnostics.DefaultTraceListener, calls the Windows API function OutputDebugString.

Any message passed to that function can be displayed by a debugger, e.g. you will see the output in the Output window of Visual Studio.

Another quite simple way to see the output of Debug.Write and/or Trace.Write is to use DebugView, a tool from Sysinternals:

DebugView is an application that lets you monitor debug output on your local system, or any computer on the network that you can reach via TCP/IP. It is capable of displaying both kernel-mode and Win32 debug output, so you don't need a debugger to catch the debug output your applications or device drivers generate, nor do you need to modify your applications or drivers to use non-standard debug output APIs.

Please note, that Debug.Write statements will not be included in a Release build, hence you would only see the output in the Debug build.

like image 65
Dirk Vollmar Avatar answered Sep 20 '22 17:09

Dirk Vollmar