System.Diagnostics.TraceSwitch.Level Property

Gets or sets the trace level that determines the messages the switch allows.

Syntax

public TraceLevel Level { get; set; }

Value

Documentation for this section has not yet been entered.

Remarks

To set the level of your System.Diagnostics.TraceSwitch, edit the configuration file that corresponds to the name of your application. In this file, you can add a switch and set its value, remove a switch, or clear all the switches previously set by the application. The configuration file should be formatted like the following example:

Example

<configuration>
  <system.diagnostics>
    <switches>
      <add name="mySwitch" value="0" />
      <add name="myNewSwitch" value="3" />
      <remove name="mySwitch" />
      <clear/>
    </switches>
  </system.diagnostics>
</configuration>
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" />.

When the erload:System.Diagnostics.TraceSwitch.#ctor constructor cannot find initial switch settings in the configuration file, the TraceSwitch.Level property of the new switch is set to TraceLevel.Off.

Setting this property updates the TraceSwitch.TraceError, TraceSwitch.TraceWarning, TraceSwitch.TraceInfo, and TraceSwitch.TraceVerbose properties to reflect the new value.

Requirements

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