.NET Framework: Create and Use Trace Listeners

How to use the built in trace listeners to trace and debug code.  Also, how to build and implement a custom trace listener.

Featured Highlights:

Requirements:

Microsoft Visual Studio.NET Professional or greater.
Windows 2000 or Windows XP.

Running the Sample:

In order to see trace output for the first trace listener example "Send trace output to a trace window" you will need to perform the following steps.  First start the project in debug mode and then set a breakpoint in the first line of the  cmdTraceToOutput_Click event handler.  Next make sure the Output window is visible.  Then step through the code with F5 to start followed by F11 keystrokes and the trace statements will be written to the output window.  For the second trace listener example "Send trace to the event log" you will need to view the event log to see the resulting output.

See Also

Trace Listeners