TraceListener.TraceOutputOptions 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置跟踪输出选项。
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
属性值
枚举值的按位组合。 默认值为 None。
- 属性
例外
由于值无效,设置操作失败。
示例
以下示例显示了控制台跟踪侦听器的属性设置 TraceOutputOptions 。 控制台跟踪侦听器是跟踪源属性中 Listeners 枚举的侦听器之一。 该代码示例是 TraceSource 类中的一个较大示例的一部分。
ts.Listeners["console"].TraceOutputOptions |= TraceOptions.Callstack;
ts.Listeners("console").TraceOutputOptions = ts.Listeners("console").TraceOutputOptions Or TraceOptions.Callstack
注解
该 TraceOutputOptions 属性确定跟踪输出的可选内容。 可以在配置文件中设置该属性,也可以在执行期间以编程方式设置属性,以专门包含代码部分的其他数据。 例如,可以设置 TraceOutputOptions 控制台跟踪侦听器的属性,以 TraceOptions.Callstack 将调用堆栈信息添加到跟踪输出。
以下 TraceOptions 类和方法不使用枚举:
该 EventLogTraceListener 类,因为它可能会导致大量数据写入日志。
和
Write类的WriteLineConsoleTraceListener和DefaultTraceListenerTextWriterTraceListener方法。Write在派生类中未重写类时类的WriteLine和TraceListener方法。