System.Diagnostics.Trace.Listeners Property

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


public static TraceListenerCollection Listeners { get; }


The list of System.Diagnostics.TraceListener objects to forward messages to.


The listeners produce formatted output from the trace output. By default, the collection contains an instance of the System.Diagnostics.DefaultTraceListener class. If you want to remove the default listener, call the TraceListenerCollection.Remove(string) method, and pass it the instance of the System.Diagnostics.DefaultTraceListener. To redirect output to the console window, add an instance of the System.Diagnostics.ConsoleTraceListener class.


The Trace.Listeners collection is shared by both the System.Diagnostics.Debug and the System.Diagnostics.Trace classes; adding a trace listener to either class adds the listener to both.


Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0,,