TraceListener.TraceOutputOptions 属性
定义
获取或设置跟踪输出选项。Gets or sets the trace output options.
public:
property System::Diagnostics::TraceOptions TraceOutputOptions { System::Diagnostics::TraceOptions get(); void set(System::Diagnostics::TraceOptions value); };
public System.Diagnostics.TraceOptions TraceOutputOptions { get; set; }
[System.Runtime.InteropServices.ComVisible(false)]
public System.Diagnostics.TraceOptions TraceOutputOptions { get; set; }
member this.TraceOutputOptions : System.Diagnostics.TraceOptions with get, set
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.TraceOutputOptions : System.Diagnostics.TraceOptions with get, set
Public Property TraceOutputOptions As TraceOptions
属性值
枚举值的按位组合。A bitwise combination of the enumeration values. 默认值为 None。The default is None.
- 属性
例外
Set 操作失败,因为值无效。Set operation failed because the value is invalid.
示例
下面的示例演示了 TraceOutputOptions 控制台跟踪侦听器的属性的设置。The following example shows the setting of the TraceOutputOptions property for a console trace listener. 控制台跟踪侦听器是跟踪源的属性中枚举的侦听器之一 Listeners 。The console trace listener is one of the listeners enumerated in the Listeners property of a trace source. 此代码示例是为类提供的更大示例的一部分 TraceSource 。This code example is part of a larger example provided for the TraceSource class.
ts.Listeners["console"].TraceOutputOptions |= TraceOptions.Callstack;
ts.Listeners("console").TraceOutputOptions = ts.Listeners("console").TraceOutputOptions Or TraceOptions.Callstack
注解
TraceOutputOptions属性确定跟踪输出的可选内容。The TraceOutputOptions property determines the optional content of trace output. 属性可以在配置文件中设置,也可以在执行过程中以编程方式进行设置,以包括专门针对一段代码的额外数据。The property can be set in the configuration file or programmatically during execution to include additional data specifically for a section of code. 例如,可以将 TraceOutputOptions 控制台跟踪侦听器的属性设置为,以 TraceOptions.Callstack 将调用堆栈信息添加到跟踪输出。For example, you can set the TraceOutputOptions property for the console trace listener to TraceOptions.Callstack to add call stack information to the trace output.
TraceOptions下面的类和方法不使用枚举:The TraceOptions enumeration is not used by the following classes and methods:
EventLogTraceListener类,因为它可能会导致大量数据写入日志。The EventLogTraceListener class, because it can cause a large volume of data to be written to the log.
WriteWriteLineConsoleTraceListener 、和类的和方法 DefaultTraceListener TextWriterTraceListener 。TheWriteandWriteLinemethods of the ConsoleTraceListener, DefaultTraceListener, and TextWriterTraceListener classes.Write WriteLine TraceListener 如果未在派生类中重写,则为类的和方法。The Write and WriteLine methods of the TraceListener class when they are not overridden in a derived class.