System.Diagnostics.TraceLevel Enumeration

Specifies what messages to output for the System.Diagnostics.Debug, System.Diagnostics.Trace and System.Diagnostics.TraceSwitch classes.

Syntax

public enum TraceLevel

Remarks

This enumeration is used by the System.Diagnostics.TraceSwitch class.

You must enable tracing or debugging to use a switch. The following syntax is compiler specific. If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler.

For more information on instrumenting your application, see System.Diagnostics.Debug and System.Diagnostics.Trace.

Note:

In the .NET Framework version 2.0, you can use text to specify the value for a switch. For example, true for a System.Diagnostics.BooleanSwitch or the text representing an enumeration value such as Error for a System.Diagnostics.TraceSwitch. The line <add name="mySwitch" value="Error" /> is equivalent to <add name="mySwitch" value="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.

Example

 <configuration>
     <system.diagnostics>
        <switches>
           <add name="mySwitch" value="4" />
        </switches>
     </system.diagnostics>
 </configuration>

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. For example, Verbose for a System.Diagnostics.TraceSwitch. The line <add name="mySwitch" value="Verbose" /> is equivalent to <add name="mySwitch" value="4" />.

The following table shows the relationship between the System.Diagnostics.TraceLevel enumeration members and their corresponding configuration file entries.

Off

0

Error

1

Warning

2

Info

3

Verbose

4

Members

Member NameDescription
Error

Output error-handling messages.

Info

Output informational messages, warnings, and error-handling messages.

Off

Output no tracing and debugging messages.

Verbose

Output all debugging and tracing messages.

Warning

Output warnings and error-handling messages.

Requirements

Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0, 2.0.0.0, 4.0.0.0