Debugging and Tracing

  • Follow


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



0
Reply Tony 5/19/2010 11:00:47 AM

On 19-05-2010 07:00, Tony Johansson wrote:
> 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
0
Reply ISO 5/20/2010 12:59:57 AM

1 Replies
231 Views

(page loaded in 0.017 seconds)


Reply: