Problem with TextwriterTraceListener

W

WT

Hello,

My code is using a class inherited from TextWriterTraceLister, creating a
new object on Application_Start and inserting it in the listeners
collection.
This has run for years,but on a new 2003 server with all last fixes, I am
unable to get a trace, it seems that our code is not called, no trace file
is writen on disk.
trying a remote debug with vs2005, we step in Application_Start after
changing web.config, and then it start tracing. But unfortunately, we were
unable to do this twice, changing web.config doesn't trigger
Application_Start anymore.
What could be the reason ?

Thanks for help
CS
 
S

Steven Cheng[MSFT]

Hello CS,

From your description, you're programmatically register a custom
TraceWriter(derived from TextTraceWriter) in ASP.NET application in
Applicaiton_Start event, however, after deploy on a new windows 2003 server
box, you found that custom trace writer not work, correct?

I've also performed some tests on my side, I've tested create and
registering a custom TextTraceWRiter in applicaiton_start event and deploy
the application on both XP and 2003 server boxes, both of them work.
Therefore, I think this approach itself should be supported and reasonable.
My code in Application_Start(global.asax) is also very straightforward:

void Application_Start(object sender, EventArgs e)
{
ClassLibrary1.CustomTextTraceWriter cttrace = new
ClassLibrary1.CustomTextTraceWriter(@"E:\temp\log_temp\dynamic_trace_log.txt
");
cttrace.Name = "dynamic_trace_writer";
System.Diagnostics.Trace.Listeners.Add(cttrace);
}

For the problem you met, I think it is likely due to something incorrectly
with the server environment. To first isolate the problem symptom, I would
suggest you perform the following tests:

** Since ASP.NET 2.0 web site support precompiled and non-precompiled
deployment model. You can try both approaches to deploy your web
application on that server to see whether it works

** You can create a new ASP.NET 2.0 web application which mainly contains
the trace writer registering and using code to see whether it also suffer
the problem on that server.


for checking the regisered trace listeners, currently I simply loop through
and printout all the registered listeners in a page's code. e.g.

========

protected void Button1_Click(object sender, EventArgs e)
{
foreach (TraceListener listener in
System.Diagnostics.Trace.Listeners)
{
Response.Write("<br/>" + listener.Name + ": " +
listener.GetType());
}
}
===========

You can also put such a simple page to verify the trace listner collection
of the running application.

If you have any other finding or anything I've missed, please feel free to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top