June 30, 2005

Info on tracing in .NET

Note: All methods of tracing mentioned here will work both in release and debug builds.

If you type the following code, you are actually invoking Page.Trace (TraceContext type) object. This object takes care of writing trace messages to trace.axd (page level tracing). For this object to work, make sure trace is enabled in web.config.


To use trace listeners, use the following code. Using this code, the trace messages will go to any listener you add to the trace listener collection. The messages will not go to trace.axd. The default listener will output the messages to OutputDebugString (normally the output window of IDE). The other options are Eventlog or text file.


You can also use conditional tracing using the following code. For this code to work, make sure a BooleanSwitch (for e.g. EnableTrace) is set to 1 in web.config under System.diagnostics section.

BooleanSwitch enableSwitch = 
     new BooleanSwitch("EnableTrace", "Some info on switch");
System.Diagnostics.Trace.WriteIf(enableSwitch.Enabled, "test");


Blogger dangelo56lidia said...

Refinance your Home loan Now, Click Here to save thousands of dollars a year on your home loan.

August 26, 2005 at 1:08 PM  
Blogger travisgilbert66495107 said...

I read over your blog, and i found it inquisitive, you may find My Blog interesting. My blog is just about my day to day life, as a park ranger. So please Click Here To Read My Blog


February 10, 2006 at 7:14 PM  
Blogger meganbrinick43999346 said...

hey, I just got a free $500.00 Gift Card. you can redeem yours at Abercrombie & Fitch All you have to do to get yours is Click Here to get a $500 free gift card for your backtoschool wardrobe

October 4, 2006 at 10:07 AM  

Post a Comment

<< Home