Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TraceSwitch and SourceSwitch - what's the difference?

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.)

like image 805
Noldorin Avatar asked Sep 11 '10 16:09

Noldorin


People also ask

Which of the following classes are used to create a trace switch?

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.


1 Answers

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.

like image 198
Henk Holterman Avatar answered Nov 10 '22 06:11

Henk Holterman