TraceLevel Перечисление
Определение
Указывает, какие сообщения должны выводиться для классов Debug, Trace и TraceSwitch.Specifies what messages to output for the Debug, Trace and TraceSwitch classes.
public enum class TraceLevel
public enum TraceLevel
type TraceLevel =
Public Enum TraceLevel
- Наследование
Поля
Error | 1 | Выводить сообщения обработки ошибок.Output error-handling messages. |
Info | 3 | Выводить информационные сообщения, предупреждения и сообщения обработки ошибок.Output informational messages, warnings, and error-handling messages. |
Off | 0 | Не выводить сообщения трассировки и отладки.Output no tracing and debugging messages. |
Verbose | 4 | Выводить все сообщения отладки и трассировки.Output all debugging and tracing messages. |
Warning | 2 | Выводить предупреждения и сообщения обработки ошибок.Output warnings and error-handling messages. |
Комментарии
Это перечисление используется классом TraceSwitch.This enumeration is used by the TraceSwitch class.
Для использования переключателя необходимо включить трассировку или отладку.You must enable tracing or debugging to use a switch. Ниже приведен синтаксис, характерный для компилятора.The following syntax is compiler specific. Если используются компиляторы, отличные от C# или Visual Basic, обратитесь к документации по компилятору.If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler.
Чтобы включить отладку в C#, добавьте
/d:DEBUG
флаг в командную строку компилятора при компиляции кода или добавьте#define DEBUG
в начало файла.To enable debugging in C#, add the/d:DEBUG
flag to the compiler command line when you compile your code, or you can add#define DEBUG
to the top of your file. В Visual Basic добавьте/d:DEBUG=True
флаг в командную строку компилятора.In Visual Basic, add the/d:DEBUG=True
flag to the compiler command line.Чтобы включить трассировку в C#, добавьте
/d:TRACE
флаг в командную строку компилятора при компиляции кода или добавьте#define TRACE
в начало файла.To enable tracing in C#, add the/d:TRACE
flag to the compiler command line when you compile your code, or add#define TRACE
to the top of your file. В Visual Basic добавьте/d:TRACE=True
флаг в командную строку компилятора.In Visual Basic, add the/d:TRACE=True
flag to the compiler command line.
Дополнительные сведения об инструментировании приложения см. в статьях Debug и Trace .For more information on instrumenting your application, see Debug and Trace.
Примечание
В .NET Framework версии 2.0 для указания значения переключателя можно использовать текст.In the .NET Framework version 2.0, you can use text to specify the value for a switch. Например, значение true
для BooleanSwitch или текст, представляющий значение перечисления, такой как Error
, для TraceSwitch.For example, true
for a BooleanSwitch or the text representing an enumeration value such as Error
for a TraceSwitch. Строка <add name="mySwitch" value="Error" />
эквивалентна <add name="mySwitch" value="1" />
.The line <add name="mySwitch" value="Error" />
is equivalent to <add name="mySwitch" value="1" />
.
В .NET Framework версиях 1,0 и 1,1 уровни трассировки в файлах конфигурации задаются с помощью целочисленного значения, соответствующего члену перечисления, а не самого члена перечисления, как показано в следующем примере.In the .NET Framework versions 1.0 and 1.1, trace levels in configuration files are set using the integer value corresponding to the enumeration member, rather than the enumeration member itself, as the following example demonstrates.
<configuration>
<system.diagnostics>
<switches>
<add name="mySwitch" value="4" />
</switches>
</system.diagnostics>
</configuration>
Помимо задания уровней трассировки с помощью целочисленного значения перечисления, уровни трассировки .NET Framework версии 2,0 можно задать с помощью текстового представления значения перечисления.In addition to setting trace levels using the integer value of the enumeration, the .NET Framework version 2.0 trace levels can be set using the text representation of the enumeration value. Например, Verbose
для TraceSwitch .For example, Verbose
for a TraceSwitch. Строка <add name="mySwitch" value="Verbose" />
эквивалентна <add name="mySwitch" value="4" />
.The line <add name="mySwitch" value="Verbose" />
is equivalent to <add name="mySwitch" value="4" />
.
В следующей таблице показана связь между TraceLevel элементами перечисления и соответствующими записями файлов конфигурации.The following table shows the relationship between the TraceLevel enumeration members and their corresponding configuration file entries.
Уровень трассировкиTrace Level | Значение файла конфигурацииConfiguration File Value |
---|---|
OffOff | 00 |
ОшибкаError | 11 |
ПредупреждениеWarning | 22 |
InfoInfo | 33 |
VerboseVerbose | 44 |