Problem with loading app.config

D

DoB

Hi,

I was trying to configure the Trace class using the app.config. I was
followig the example configurations in the MSDN.
However, as I debug the program, the Trace class seems to ignore the
configuration. For example - it has its default and only listener while I
removed it and added some other listeners in a config file.

Am I missing something? Is any explicit call needed to load the trace
configuration part?

DoB
 
P

Peter K

DoB said:
Hi,

I was trying to configure the Trace class using the app.config. I was
followig the example configurations in the MSDN.
However, as I debug the program, the Trace class seems to ignore the
configuration. For example - it has its default and only listener
while I removed it and added some other listeners in a config file.

Am I missing something? Is any explicit call needed to load the trace
configuration part?

Hi - I think you need to be aware that "app.config" is not the real name of
the configuration file your program uses (at least as far as I have seen).
This might be the name you see in Visual Studio, but when you compile the
file is automatically renamed to something like
"application_name.exe.config".

So check this file exists and is in the right place.

/Peter
 
S

Som Nath Shukla

<configuration>
<system.diagnostics>
<switches>
<add name="DemoApp.Switch" value="Information"/>
</switches>
<trace autoflush="true" indentsize="5">
<listeners>
<add name="DemoListener" type="System.Diagnostics.XmlWriterTraceListener"
initializeData="output.xml" />
<remove name="Default" />

<add name="DemoListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="output.txt" />
<remove name="Default" />
<add name="DemoListener"
type="System.Diagnostics.DelimitedListTraceListener"
delimiter="|"
initializeData="C:\\output.txt"/>
<remove name="Default" />

</listeners>
</trace>

</system.diagnostics>
</configuration>


i have different listener u can use it according to uer convience
 
D

DoB

OK. Solved.
It was actually loading, but the configuration was incorrect :)
Sorry for troubling.

DoB
 

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