Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Specifies what messages to output for the Debug, Trace and TraceSwitch classes.
public enum class TraceLevel
public enum TraceLevel
type TraceLevel =
Public Enum TraceLevel
Name | Value | Description |
---|---|---|
Off | 0 | Output no tracing and debugging messages. |
Error | 1 | Output error-handling messages. |
Warning | 2 | Output warnings and error-handling messages. |
Info | 3 | Output informational messages, warnings, and error-handling messages. |
Verbose | 4 | Output all debugging and tracing 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.
In .NET Framework app configuration files, 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" />
. You can also set trace levels using the integer value of the enumeration. 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 feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in