<add> Element for <switches>

Specifies the level where a trace switch is set.

<configuration>
   <system.diagnostics>
      <switches>
         <add>

<add name="switch name"
     value="value"/>

Required Attributes

Attribute Description
name Specifies the name of the switch. The value of this attribute corresponds to the displayName parameter that is passed to switch constructor.
value Specifies the level of the switch.

Remarks

You can change the level of a trace switch by putting it in a configuration file. If the switch is a BooleanSwitch, you can turn it on and off. If the switch is a TraceSwitch, you can assign different levels to it to specify the types of trace or debug messages the application outputs.

Example

The following example shows how to use the <add> element to set the General trace switch to the TraceLevel.Error level, and enable the Data Boolean trace switch.

<configuration>
   <system.diagnostics>
      <switches>
         <add name="General" value="4" />
         <add name="Data" value="1" />
      </switches>
   </system.diagnostics>
</configuration>

Configuration File

This element can be used in the machine configuration file (Machine.config) and the application configuration file.

See Also

Trace and Debug Settings Schema | Switch Class | TraceSwitch Class | BooleanSwitch Class