Can't enable tracing via app.config

  • Thread starter Thread starter Brad Wood
  • Start date Start date
B

Brad Wood

I've used tracing before, but today I've tried everything and can't get
a simple sample working.

This is my app config (I've also tried specifying a fully qualified type
name for the type attribute of the add element):
<configuration>
<system.diagnostics>
<trace autoflush="false">
<listeners>
<add name="bob"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="E:\log.txt" />
</listeners>
</trace>
</system.diagnostics>
</configuration>

I've added the #define DEBUG directive to the only code file in my
project. When I run the app and examine the Listeners collection, there
is only the one DefaultTraceListener, no TextWriterTraceListener.

I can't figure out why...
 
Finally discovered what I was doing. I added an additional config file
to my (existing) test project so the new config file wasn't being used
at all.
Also, I didn't need the #define DEBUG or #define TRACE directive even
though the documentation says one or the other is required.
 
Back
Top