TraceOptions TraceOptions TraceOptions TraceOptions Enum


指定要写入跟踪输出中的跟踪数据选项。Specifies trace data options to be written to the trace output.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class TraceOptions
public enum TraceOptions
type TraceOptions = 
Public Enum TraceOptions


Callstack Callstack Callstack Callstack 32

写入调用堆栈,该堆栈由 StackTrace 属性的返回值表示。Write the call stack, which is represented by the return value of the StackTrace property.

DateTime DateTime DateTime DateTime 2

写入日期和时间。Write the date and time.

LogicalOperationStack LogicalOperationStack LogicalOperationStack LogicalOperationStack 1

写入逻辑操作堆栈,该堆栈由 LogicalOperationStack 属性的返回值表示。Write the logical operation stack, which is represented by the return value of the LogicalOperationStack property.

None None None None 0

不写入任何元素。Do not write any elements.

ProcessId ProcessId ProcessId ProcessId 8

写入进程标识,该标识由 Id 属性的返回值表示。Write the process identity, which is represented by the return value of the Id property.

ThreadId ThreadId ThreadId ThreadId 16

写入线程标识,该标识由当前线程的 ManagedThreadId 属性的返回值表示。Write the thread identity, which is represented by the return value of the ManagedThreadId property for the current thread.

Timestamp Timestamp Timestamp Timestamp 4

写入时间戳,该时间戳由 GetTimestamp() 方法的返回值表示。Write the timestamp, which is represented by the return value of the GetTimestamp() method.


下面的代码示例演示如何使用TraceOptions枚举来以编程方式设置TraceOutputOptions控制台跟踪侦听器的属性。The following code example shows the use of the TraceOptions enumeration to programmatically set 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


此枚举的跟踪侦听器用于确定哪个选项或元素,应包括在跟踪输出。This enumeration is used by trace listeners to determine which options, or elements, should be included in the trace output. 跟踪侦听器存储中的跟踪选项TraceOutputOptions属性。Trace listeners store the trace options in the TraceOutputOptions property.

下面的示例演示如何使用traceOutputOptions属性指定的跟踪输出选项ConsoleTraceListener的启用了使用配置文件。The following example shows the use of the traceOutputOptions attribute to specify the trace output options for a ConsoleTraceListener that is enabled using a configuration file.

    <trace autoflush="false" indentsize="4">  
        <add name="consoleListener"  
          traceOutputOptions="ProcessId, DateTime" />  

有关将跟踪侦听器添加到应用程序配置文件的详细信息,请参阅<侦听器>For details about adding trace listeners to the application configuration file, see <listeners>.

TraceOptions枚举未由以下类和方法:The TraceOptions enumeration is not used by the following classes and methods: