Problem with loading app.config

  • Thread starter Thread starter DoB
  • Start date Start date
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
 
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
 
<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
 
OK. Solved.
It was actually loading, but the configuration was incorrect :-)
Sorry for troubling.

DoB
 
Back
Top