TraceListenerCollection.Add(TraceListener) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将 TraceListener 添加到列表。
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
参数
- listener
- TraceListener
要添加到列表的 TraceListener。
返回
插入新侦听器的位置。
示例
以下示例创建一个 TextWriterTraceListener 输出到控制台屏幕的 。 然后,代码将新的侦听器添加到 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)