Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

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)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...