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.)
The difference is that
TraceSwitch
works withTrace
messages whereasSourceSwitch
works withTraceSource
messages, which associate the messages with their source. So with aSourceSwitch
you can configure your listeners based on on where the trace messages came from.I agree the documentation doesn't directly point out the difference, but dig around in the related
TraceSource
class documentation and you'll find this:There is also a sample showing you how to configure a
SourceSwitch
to turn off tracing from a trace source.