Eksporter (0) Skriv ut
Vis alt
Expand Minimize
EN
Dette innholdet er ikke tilgjengelig på ditt språk, men her er den engelske versjonen.

TraceLevel Enumeration

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

Namespace:  System.Diagnostics
Assembly:  System (in System.dll)

public enum TraceLevel

Member nameDescription
ErrorOutput error-handling messages.
InfoOutput informational messages, warnings, and error-handling messages.
OffOutput no tracing and debugging messages.
VerboseOutput all debugging and tracing messages.
WarningOutput warnings and error-handling messages.

This enumeration is used by the 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.

  • 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. In Visual Basic, add the /d:DEBUG=True flag to the compiler command line.

  • 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. In Visual Basic, add the /d:TRACE=True flag to the compiler command line.

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

NoteNote

In the .NET Framework version 2.0, you can use text to specify the value for a switch. For example, true for a BooleanSwitch or the text representing an enumeration value such as Error for a 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.

 <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 TraceSwitch. The line <add name="mySwitch" value="Verbose" /> is equivalent to <add name="mySwitch" value="4" />.

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

Trace Level

Configuration File Value

Off

0

Error

1

Warning

2

Info

3

Verbose

4

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Vis:
© 2014 Microsoft