Επεξεργασία

Κοινή χρήση μέσω


TraceListenerCollection.Add(TraceListener) Method

Definition

Adds a TraceListener to the list.

public:
 int Add(System::Diagnostics::TraceListener ^ listener);
public int Add (System.Diagnostics.TraceListener listener);
member this.Add : System.Diagnostics.TraceListener -> int
Public Function Add (listener As TraceListener) As Integer

Parameters

listener
TraceListener

A TraceListener to add to the list.

Returns

The position at which the new listener was inserted.

Examples

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

/* Create a listener, which outputs to the console screen, and 
 * add it to the trace listeners. */
TextWriterTraceListener^ myWriter = gcnew TextWriterTraceListener;
myWriter->Writer = System::Console::Out;
Trace::Listeners->Add( myWriter );
/* Create a listener, which outputs to the console screen, and
  * add it to the trace listeners. */
TextWriterTraceListener myWriter = new TextWriterTraceListener();
myWriter.Writer = System.Console.Out;
Trace.Listeners.Add(myWriter);
' Create a listener, which outputs to the console screen, and
' add it to the trace listeners. 
Dim myWriter As New TextWriterTraceListener()
myWriter.Writer = System.Console.Out
Trace.Listeners.Add(myWriter)

Applies to

See also