Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
TraceLevel Enumeration
Collapse the table of content
Expand the table of content

TraceLevel Enumeration

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

[Visual Basic]
<Serializable>
Public Enum TraceLevel
[C#]
[Serializable]
public enum TraceLevel
[C++]
[Serializable]
__value public enum TraceLevel
[JScript]
public
   Serializable
enum TraceLevel

Remarks

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 using 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.

When you set the trace level using a configuration file, you specify an integer value that corresponds to an 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>

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

Members

Member name Description
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

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

System.Diagnostics Namespace | Debug | Trace | TraceSwitch

Show:
© 2015 Microsoft