Click or drag to resize

Tracing Listeners

Home

Trace messages are received by listeners. The purpose of a listener is to collect, store, and route tracing messages. Listeners direct the tracing output to an appropriate target, such as a log, window, or text file. One such listener, the DefaultTraceListener, is automatically created and initialized when tracing is enabled. If you want to trace an output to be directed to any additional sources, you must create and initialize additional trace listeners. The listeners you create should reflect your individual needs. For example, you want a text record of all trace outputs. In this case, create a listener that writes all outputs to a new text file when enabled. There are several types of predefined listeners:

  • TextWriterTraceListener outputs information as a text to the console or to a file.

  • EventLogTraceListener redirects the output to an event log.

  • ConsoleTraceListener directs the tracing or debugging output to either the standard output or the standard error stream.

  • DelimitedListTraceListener directs the tracing or debugging output to a text writer, such as a file stream. The trace output is in a delimited text format that uses a delimiter specified by the Delimiter property (this is a useful option to have an output in CSV format).

  • XmlWriterTraceListener directs the tracing or debugging output as XML-encoded data to a file stream (this is a useful option to have an output in XML format).