Listeners Property
Collapse the table of content
Expand the table of content

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

Not applicable.

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 

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

© 2015 Microsoft