Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

SourceSwitch Class

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

Namespace: System.Diagnostics
Assembly: System (in system.dll)

public class SourceSwitch : Switch
public class SourceSwitch extends Switch
public class SourceSwitch extends Switch
Not applicable.

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

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

To configure a SourceSwitch, 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 TraceSource trace method calls the ShouldTrace method before calling the listeners. If the ShouldTrace method returns false, the trace is ignored and the trace method exits. If the ShouldTrace method returns true, the trace is passed to the listeners.

TopicLocation
How to: Configure Trace Switches.NET Framework: Debugging
How to: Create and Initialize Trace Switches.NET Framework: Debugging
How to: Configure Trace Switches.NET Framework: Debugging
How to: Create and Initialize Trace Switches.NET Framework: Debugging

System.Object
   System.Diagnostics.Switch
    System.Diagnostics.SourceSwitch

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft