TraceOptions Перечисление
Определение
Задает параметры данных трассировки, записываемые в выходные данные трассировки.Specifies trace data options to be written to the trace output.
Это перечисление имеет атрибут FlagsAttribute, который разрешает побитовое сочетание значений его элементов.
public enum class TraceOptions
public enum TraceOptions
[System.Flags]
public enum TraceOptions
type TraceOptions =
[<System.Flags>]
type TraceOptions =
Public Enum TraceOptions
- Наследование
- Атрибуты
Поля
Callstack | 32 | Записывает стек вызова, представленный возвращаемым значением свойства StackTrace.Write the call stack, which is represented by the return value of the StackTrace property. |
DateTime | 2 | Записывает дату и время.Write the date and time. |
LogicalOperationStack | 1 | Записывает стек логических операций, представленный возвращаемым значением свойства LogicalOperationStack.Write the logical operation stack, which is represented by the return value of the LogicalOperationStack property. |
None | 0 | Не записывает элементы.Do not write any elements. |
ProcessId | 8 | Записывает стек идентификации процесса, представленный возвращаемым значением свойства Id.Write the process identity, which is represented by the return value of the Id property. |
ThreadId | 16 | Записывает стек удостоверений процесса, представленный возвращаемым значением свойства ManagedThreadId для текущего потока.Write the thread identity, which is represented by the return value of the ManagedThreadId property for the current thread. |
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.
<configuration>
<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="consoleListener"
type="System.Diagnostics.ConsoleTraceListener"
traceOutputOptions="ProcessId, DateTime" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
Дополнительные сведения о добавлении прослушивателей трассировки в файл конфигурации приложения см. в разделе < Listeners > .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:
EventLogTraceListenerКласс, поскольку он может привести к записи большого объема данных в журнал.The EventLogTraceListener class, because it can cause a large volume of data to be written to the log.
Write
Методы иWriteLine
ConsoleTraceListener DefaultTraceListener классов, и TextWriterTraceListener .TheWrite
andWriteLine
methods 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.