<system.diagnostics> in web.config

  • Thread starter Thread starter Jiho Han
  • Start date Start date
J

Jiho Han

I have the following defined in web.config under <configuration> node:

<system.diagnostics>

<switches>

<add name="MainSwitch" value="4"/>

</switches>

<trace autoflush="true" indentsize="4">

<listeners>

<add name="myListenere" type="System.Diagnostics.TextWriterTraceListener"
initializeData="c:\myListener.log" />

</listeners>

</trace>

</system.diagnostics>

When I tried to load a page, I get a configuration exception that says there
was an exception in configuration section handler. Can some tell me what is
wrong with this configuration?



Thanks
 
Wild guess, but what if you escape the \ in ="c:\myListener.log" /> by doing
=@"C:\myListener.lob"/>
 
Yeah, nevermind.. I took your Xml snippet and stuck it in my web.config file
and everything was ok.

Here's my web.config file, I just deleted everything in <appsettings> for
brevity

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>

</appSettings>
<system.web>
<compilation defaultLanguage="c#" debug="true" />
<customErrors mode="RemoteOnly" />
<authentication mode="Forms">
<forms loginUrl="login.aspx" name="adAuthCookie" timeout="240" path="/"
/>
</authentication>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
<identity impersonate="true"></identity>
<trace enabled="false" requestLimit="10" pageOutput="true"
traceMode="SortByTime" localOnly="true" />
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false" timeout="240" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>
<system.diagnostics>
<switches>
<add name="MainSwitch" value="4" />
</switches>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="myListenere"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="c:\myListener.log" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
 
I see you have asp.net tracing turned off. (<trace enabled="false">) Maybe
that's it? Hmm...
I got a lot of stuff happening in web.config. So maybe I should try it on a
default one.
Have you tried writing to trace, and did you get output in your specified
file?

BTW, I decided that I am going to use log4net for my tracing but it'd still
be useful to know whether this works or not.

Thanks for your help.
Jiho
 
Back
Top