Trace.Listeners Property
.NET Framework 3.0
Gets the collection of listeners that is monitoring the trace output.
Namespace: System.Diagnostics
Assembly: System (in system.dll)
Assembly: System (in system.dll)
public: static property TraceListenerCollection^ Listeners { TraceListenerCollection^ get (); }
/** @property */ public static TraceListenerCollection get_Listeners ()
public static function get Listeners () : TraceListenerCollection
Not applicable.
Property Value
A TraceListenerCollection that represents a collection of type TraceListener monitoring the trace output.The listeners produce formatted output from the trace output. By default, the collection contains an instance of the DefaultTraceListener class. If you want 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 class.
The following example creates a ConsoleTraceListener that outputs to the console screen. The code then adds the new listener to the Listeners.
// Create a ConsoletTraceListener and add it to the trace listeners. #if defined(TRACE) ConsoleTraceListener^ myWriter = gcnew ConsoleTraceListener( ); Trace::Listeners->Add( myWriter ); #endif
/* Create a ConsoleTraceListener and add it to the trace listeners.
*/
ConsoleTraceListener myWriter =
new ConsoleTraceListener();
Trace.get_Listeners().Add(myWriter);
// Create a ConsoletTraceListener and add it to the trace listeners. @if(@TRACE) var myWriter : ConsoleTraceListener = new ConsoleTraceListener() Trace.Listeners.Add(myWriter) @end
- SecurityPermission for operating with unmanaged code. Security action: Demand. Associated enumeration: SecurityPermissionFlag.UnmanagedCode
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, 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.Community Additions
ADD
Show: