TraceListenerCollection.Add(TraceListener) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Samarbejd med os på GitHub
Kilden til dette indhold kan findes på GitHub, hvor du også kan oprette og gennemse problemer og pullanmodninger. Du kan få flere oplysninger i vores vejledning til bidragydere.