.Net has some great tracing features already built in. One of them is trace switches. You can create your own switches for each business process that needs tracing, such as trying to debug a tedious problem in the development environment. You can set switches in your config to various levels, and then call them from code. The trace levels (from MSDN) are:
Trace Level | Configuration File Value |
Off | 0 |
Error | 1 |
Warning | 2 |
Info | 3 |
Verbose | 4 |
You could set the following switches in your config. If the switch is omitted from the config file (and not instantiated elsewhere), then it is simply ignored.
|
You could then instantiate the switch in code like so:
|
Finally, you could access the various level by calling the Trace
TraceSwitches provide an easy way for simple instrumentation of our business processes.
No comments:
Post a Comment