By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,357 Members | 982 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,357 IT Pros & Developers. It's quick & easy.

Getting More Tracing Output in ASP.NET App.

P: n/a
We have an ASP.NET 2.0 (C#) app and we're trying to add tracing into it.
The tracing functionality within .NET is great, but when we output this to a
file, it's kind of sparse.

So, we're looking for ideas on how to get more tracing info. output to our
log file than what's currently output by calling the Write methods.
Here are some snippets of what we're thinking of:

Web.config
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="TextWriterTraceListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="D:\Temp\TraceFiles\Application_Tra ceFile.log"/>
</listeners>
</trace>
</system.diagnostics>

..aspx page
protected void Page_Load(object sender, EventArgs e)
{
Trace.Write("Web Application", "Trace test from a web application
(before call to method in class library).");

Tracing.Trace(); // Call to method in library, to get tracing info.
from a library too

Trace.Write("Web Application", "Trace test from a web application
(after call to method in class library).");
}

..cs class library
public static void Trace()
{
// Just for testing tracing from a library and an ASP.NET app
System.Diagnostics.Trace.WriteLine("Trace test from a class
library (using WriteLine).", "Tracing Class Library");
}

In the tracing log file, we get:

aspx.page: Begin PreInit

....

aspx.page: Begin Load
Web Application: Trace test from a web application (before call to method in
class library).
Tracing Class Library: Trace test from a class library (using WriteLine).
WhoAmI Web Application: Trace test from a web application (after call to
method in class library).
aspx.page: End Load

....

aspx.page: End Render

Is there any way to have the built-in tracing spit out more info. to the
file? For example, if you have tracing turned on to display at the bottom
of the web page, it generates a lot of useful info. Is there any way to get
all that info. logged to a file?

Thank you.

May 11 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.