TraceOptions Enum
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.
Specifies trace data options to be written to the trace output.
This enumeration supports a bitwise combination of its member values.
public enum class TraceOptions
[System.Flags]
public enum TraceOptions
[<System.Flags>]
type TraceOptions =
Public Enum TraceOptions
- Inheritance
- Attributes
Fields
Name | Value | Description |
---|---|---|
None | 0 | Do not write any elements. |
LogicalOperationStack | 1 | Write the logical operation stack, which is represented by the return value of the LogicalOperationStack property. |
DateTime | 2 | Write the date and time. |
Timestamp | 4 | Write the timestamp, which is represented by the return value of the GetTimestamp() method. |
ProcessId | 8 | Write the process identity, which is represented by the return value of the Id property. |
ThreadId | 16 | Write the thread identity, which is represented by the return value of the ManagedThreadId property for the current thread. |
Callstack | 32 | Write the call stack, which is represented by the return value of the StackTrace property. |
Examples
The following code example shows the use of the TraceOptions enumeration to programmatically set the TraceOutputOptions property for a console trace listener. The console trace listener is one of the listeners enumerated in the Listeners property of a trace source. 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
Remarks
This enumeration is used by trace listeners to determine which options, or elements, should be included in the trace output. Trace listeners store the trace options in the TraceOutputOptions property.
The following example shows the use of the traceOutputOptions
attribute to specify the trace output options for a ConsoleTraceListener. Using a configuration file like this is only possible in .NET Framework apps.
<configuration>
<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="consoleListener"
type="System.Diagnostics.ConsoleTraceListener"
traceOutputOptions="ProcessId, DateTime" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
For details about adding trace listeners to the application configuration file, see <listeners>.
The TraceOptions enumeration is not used by the following classes and methods:
The EventLogTraceListener class, because it can cause a large volume of data to be written to the log.
The
Write
andWriteLine
methods of the ConsoleTraceListener, DefaultTraceListener, and TextWriterTraceListener classes.The Write and WriteLine methods of the TraceListener class when they are not overridden in a derived class.