So I'm probably missing the obvious here, but what actually is the difference between the functionality of the TraceSwitch
and SourceSwitch
classes?
They both give identical summary descriptions:
Provides a multilevel switch to control tracing and debug output without recompiling your code.
Are the Remarks sections are oddly similar to my eyes. Could someone please clarify the difference in their functionality and usage cases?
(For completeness, I'm using switches with my TraceSource
object, rather than the old static Trace
class, though I doubt it makes much difference.)
In order to use trace switches, you must first create them and place them in your code. There are two predefined classes from which you can create switch objects: the System. Diagnostics. BooleanSwitch class and the System.
The (older) TraceSwitch basically is a TraceLevel object to be used in combination with the static Trace class.
The (newer) TraceSource combines a TraceLevel concept with actual output methods.
As a consequence, in a large App you can use multiple TraceSwitches to configure Trace settings for different parts (GUI, DAL) of the program but all output will be send to the same TraceListener(s).
With a TraceSource you can have independent output channels. And a slightly better API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With