TraceLevel 枚举

定义

指定为 DebugTraceTraceSwitch 类输出的消息。Specifies what messages to output for the Debug, Trace and TraceSwitch classes.

public enum class TraceLevel
public enum TraceLevel
type TraceLevel = 
Public Enum TraceLevel
继承
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. 例如,为 BooleanSwitch 指定 true 或表示枚举值的文本,例如为 TraceSwitch 指定 ErrorFor 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
T:System.Diagnostics.SwitchInfo 33
详细Verbose 44

适用于

另请参阅