Debugging and Tracing

T

Tony Johansson

Hi!

I'm reading in a book and it says the following.
Trace.Listeners.Clear();
Trace.Listeners.Add(new XmlWriterTraceListener(@"C:\output.xml"));
Trace.AutoFlush = true;
Trace.WriteLine("This is a test");

This can also be configured using the following.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="5">
<listeners>
<add name="DemoListener"
type="System.Dignostics.XmlWriterTraceListener" initializeData="output.xml"
/>
<remove name="Default" />
</listeners>
</trace>
</system.diagonstics>
</configuration>

Now to my question what do I have to write in the code to be able to use
this configuration file ?

//Tony
 
A

Arne Vajhøj

I'm reading in a book and it says the following.
Trace.Listeners.Clear();
Trace.Listeners.Add(new XmlWriterTraceListener(@"C:\output.xml"));
Trace.AutoFlush = true;
Trace.WriteLine("This is a test");

This can also be configured using the following.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="5">
<listeners>
<add name="DemoListener"
type="System.Dignostics.XmlWriterTraceListener" initializeData="output.xml"
/>
<remove name="Default" />
</listeners>
</trace>
</system.diagonstics>
</configuration>

Now to my question what do I have to write in the code to be able to use
this configuration file ?

Do you need to do anything?

I would expect the Trace class to read it from
web.config/app.config automatically.

Arne
 

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

Top