mike55 Posted January 8, 2009 Posted January 8, 2009 1. XMLWriterTraceListener 2. TextWriterTraceListener 3. DefaultWriterTraceListener Ok, I am going through the MCTS book for exam 70-536, I am currently looking at chapter 10, lesson 2 "Debugging and Tracing". The lesson talks about using Trace listeners and how they can be implemented using either code or in the .config file. I have a basic web application, so I have tried to implement the XMLWriterTraceListener in my web.config. I would intend to try out the other 2 listeners also. Now, to apply the changes to the config file only, the following changes need to be made: <system.diagnostics> <trace autoflush="true" indentsize="5"> <listeners> <add name="xyz" type="System.Diagnostics.XMLWriterTraceListener" initializeData="output.xml"/> <remove name="Default"/> </listeners> </trace> </system.diagnostics> The alternative approach is to do the following in code: Trace.Listeners.Clear() Trace.Listeners.Add(New XMLWriterTraceListener("C:\output.xml")) Trace.Autoflush = True Trace.WriteLine("This is a Test") None of the above two code segments worked for me in my web application, for the second code segment, I got an error message: "Listeners is not a member of System.Web.TraceContext". I then switched my two code segments to a sample windows application. The changes to the app.config coupled with the line: Trace.WriteLine("hello world...") did not appear to work. When I used the second code segment (having removed the changes from the config file), the tracing worked. Have I missed something with regards to the app.config file? Should the changes to the app.config file have worked in my web project? Mike55. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Administrators PlausiblyDamp Posted January 9, 2009 Administrators Posted January 9, 2009 You are possibly getting a name clash between the HttpContext's Trace object and the Trace object from System.Diagnostics Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.