A variety of trace
statements to use a Boolean switch you need to create an instance of your code
the instance should have the same name as one of the switch is defined in the
web.config file is the switch name in your code doesn't match any switches in
web.config the net switches disabled the trace switch class let.
You enable
trace switch for various tracing levels so that the trace messages specified
for that level in all levels below it appear if you disable switch the trace
messages do not appear and finally there's a source switch this class provides
a multilevel switch that lets you control tracing and debug output this switch
is mainly used as the object behind the switch property of the trace source
class in the trace switch class provides a lot more granularity.
Than the simple
on-off Boolean switch class and contains various tracing levels you can specify
off which outputs no messages error which outputs only error messages warning
for both error and warning messages info for informational warning at error
messages and verbose which outputs all messages to each of these tracing levels
includes all of the messages at the defined level as well as the lower level
reading up in the list and when your code checks a trace switch for particular
level the switch returns true.
If it is been sent to that level or any level
above it which means that if it's true you should output that message right one
more thing to talk about men will look at how this is implemented in code
switches are configured in the switches section within the system.diagnostics
element within web.config so I have the system.diagnostics element which is a
child switches and that I define whatever switches that I want to include and
these names are custom names the name attribute is any name that you define.
This can be the name that you referred to within your code and the value is one
of the values is appropriate for the type of switch so for example you can set
the Boolean switch to 01 and the multi-switch to value from 04 relating to the
particular level that you want zero first off and four refers to verbose okay
let's go ahead and take a look at the sample application that implement some of
these features the default for deployed application is to have all trace
switches disabled if you have a problem with the application.
Then you can edit
the web.config file to flip the switches and activate any trace listeners you
may have in your code when the code executes and creates an instance of switch
object for the first time it checks the web.config file to see the level of
trace information you've configured if any and unconditionally produces output
based on the settings it finds there so the first thing we need to do is modify
the web.config, reduce other config file and steal.
0 comments:
Post a Comment