Will the convoluted but you get used to it after a while so
I passed now has the path to the application and then we can knew of the file
stream defining it as a motive either open Hate giving it the name of trace log
and you put that within the application path now the text listeners to find and
we go ahead and add it to the listeners collection of the trace object each
listener that you define is going to require different steps to set it up.
Because it's going to be sending its information to different media different
devices different locations whatever you create you should tear down to the
cleanup method takes care of clearing out the listeners from the trace
collection to the clear method takes care of clearing out all the listeners
that are associated with the trace object and it closes down any of the
listeners when you execute the close method it flushes any messages that have
been cached and writes them to whatever output media is appropriate for that
type of listener.
Can take a look at how to use these listeners over into the
code behind my default.aspx page and scroll down to the right to listeners
method this procedure shows how you can use the listeners and switches in your
code the first thing it does is calls initialize listener method on the trace
listen object in order to initialize listeners that news of the string builder
which organ he used to build the string in order to display on the page at this
point were ready to start outputting messages so we append some text to that
string builder but we do it conditionally based on whether or not that Boolean.
Switch is enabled or not if it is enabled then we went to string it is not
enabled that we don't write the string and then we can do some conditional operations
based on whether that's which is enabled in this case really do a trace right
as well as a right line to the trace object the rest of the code within this
procedure just test to see whether switches are enabled and outputs various
messages this line of code shows how you can test to see whether the
multi-switch list this line of code shows how you can test to see whether the
multi-switch trace.
Which is set to at least the error level and if it is then
it's going to output a message it sent a warning it's good output that message
and this one and if it is set to the info level or better than allow put this
information to the big message of this procedure is to show how you can
conditionally output different kinds of information based on whether a particular
switch is set or sent to a specific level right at the end of the method we
call the two string method of the string builder and that places that
information within that message variable and then.
0 comments:
Post a Comment