Export (0) Print
Expand All

Debug.Listeners Property

Gets the collection of listeners that is monitoring the debug output.

Namespace: System.Diagnostics
Assembly: System (in system.dll)

public static TraceListenerCollection Listeners { get; }
/** @property */
public static TraceListenerCollection get_Listeners ()

public static function get Listeners () : TraceListenerCollection

Property Value

A TraceListenerCollection representing a collection of type TraceListener that monitors the debug output.

The listeners produce formatted output from the debug output. By default, the collection contains an instance of the DefaultTraceListener class. To remove the default listener, call the Remove method, and pass it the instance of the DefaultTraceListener. To redirect output to the console window, add an instance of the ConsoleTraceListener. To redirect output to a file or stream, add an instance of the TextWriterTraceListener.

The following example creates a TextWriterTraceListener that outputs to the console screen. The code then adds the new listener to the Listeners.

/* Create a listener that outputs to the console screen, and 
  * add it to the debug listeners. */
 TextWriterTraceListener myWriter = new 
    TextWriterTraceListener(System.Console.Out);
 Debug.Listeners.Add(myWriter);


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft