System 2.0.0.0 4.0.0.0 System.Diagnostics.Switch

The property of the class is a object. The class provides a property to test the event level of the switch. The property gets or sets the switch's value.

You can set the event level of a through the application configuration file and then use the configured level in your application. Alternatively, you can create a in your code and set the level directly, to instrument a specific section of code.

To configure a , edit the configuration file that corresponds to the name of your application. Within this file, you can set a switch's value or clear all the switches previously set by the application. The configuration file should be formatted as shown in the following example.

`<switches> <add name="SourceSwitch" value="Verbose"></add> </switches>`

The switch is used to check whether a trace should be propagated or ignored. Each trace method calls the method before calling the listeners. If the method returns false, the trace is ignored and the trace method exits. If the method returns true, the trace is passed to the listeners.

Provides a multilevel switch to control tracing and debug output without recompiling your code.

- Constructor
  2.0.0.0
  4.0.0.0
  To be added.

  The parameter is used to set the value of the property.

  To set the level of your , edit the configuration file that corresponds to the name of your application. Within this file, you can add a switch and set its value, remove a switch, or clear all the switches previously set by the application. To add a source switch, the configuration file should be formatted as shown in the following example.

  <configuration> <system.diagnostics> <switches> <add name="SourceSwitch" value="Verbose" ></add> </switches> </system.diagnostics> </configuration>

  Initializes a new instance of the class, specifying the name of the source.

- Constructor
  2.0.0.0
  4.0.0.0

  The parameter is used to set the value of the property; the parameter is saved as a field and used to initialize the property on first reference.

  If the switch is defined in a configuration file and the value attribute is specified, the configuration file value takes precedence and the is ignored.

  To set the level of your , edit the configuration file that corresponds to the name of your application. Within this file, you can add a switch and set its value, remove a switch, or clear all the switches previously set by the application. To add a source switch, the configuration file should be formatted as shown in the following example.

  <configuration> <system.diagnostics> <switches> <add name="SourceSwitch" value="Verbose" ></add> </switches> </system.diagnostics> </configuration>

  Initializes a new instance of the class, specifying the display name and the default value for the source switch.

  The name of the source switch.
  The default value for the switch.
- Property
  2.0.0.0
  4.0.0.0
  System.Diagnostics.SourceLevels To be added.

  This property gets its value from the property. Setting this property also modifies the property.

  For extensibility, the property can be set to any integer, rather than being limited to a enumeration value.

  Gets or sets the level of the switch.

- Method
  2.0.0.0
  4.0.0.0
  System.Void

  The method converts the new value of the property to the integer representation of the matching field in the enumeration, and then uses this integer to set the property.

  Invoked when the value of the property changes.

- Method
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  This method is called by the Trace methods in the class to determine whether listeners should be called to write a trace.

  Application code should not call this method; it is intended to be called only by methods in the class.

  Determines if trace listeners should be called, based on the trace event type.

  True if the trace listeners should be called; otherwise, false.

  One of the values.