views:

331

answers:

1

I'm trying to analyze some running times for various methods in my default.aspx.cs page. I need to use TextWriterTraceListener.

I have it set up so that output is being redirected to the file. However, the data isn't what I want.

As far as I can tell if you simply enable tracing and have the trace appended to the bottom of the webpage you get this nice table with times in between trace calls. It's these times that I care about. An example can be seen here...

http://dotnetperls.com/trace-basics-aspnet

Using TextWriterTraceListener say, for example, I add to the top of Page_Init

System.Diagnostics.Trace.TraceInformation("Begin Page_Init");

and to the bottom...

System.Diagnostics.Trace.TraceInformation("End Page_Init");

here's the output I get...

WebDev.WebServer.EXE Information: 0 : Begin Page_Init
WebDev.WebServer.EXE Information: 0 : End Page_Init

This isn't helpful to me. For one, I don't know what the 0 means. Maybe it's the time, but it's not recognizing anything less than 1 second? I don't know.

I can't find any good resources on this, but I know I have to be missing something, this seems not very useful as is. How do I get times without resorting to some sort of trickery?

Edit: I should note that I found this...

http://stackoverflow.com/questions/1171670/formatting-trace-output

However, it seems the consensus is to use log4net or roll your own. Is this really the answer? I'm unsure how this method of tracing could be that useful without any type of timing.

A: 

Ok, well writing out Stopwatch values works fine so I guess I'll just do that. It just seems like it should work just the same as when you enable Tracing to the page. I guess not though.

Anyway as far as I can tell, the answer is to use your own method of timing in conjunction with TextWriterTraceListener.

Carter