Can't enable tracing via app.config

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...
 
B

Brad Wood

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.
 

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