Tracing and Web.Config

G

Guest

I cannot get a clean compile if I add Trace configuration info into my
web.config. This generates an error:

<configuration>
<system.diagnostics>
<switches>
<add name="MyTraceSwitch" value="4" />
</switches>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="TextListener"
type="System.Diagnostics.TextWriterTraceListener" initializeData="c:\my.log"
/>
<remove type="System.Diagnostics.DefaultTraceListener" />
</listeners>
</trace>
</system.diagnostics>
<configuration>

If i remove the Trace section but leave in the TraceSwitch part like:

<configuration>
<system.diagnostics>
<switches>
<add name="MyTraceSwitch" value="4" />
</switches>
</system.diagnostics>
<configuration>

the app compiles but when I use the code:

TraceSwitch MyTraceSwitch = new TraceSwitch("MyTraceSwitch","My Web Service");

then check the value of MyTraceSwitch.TraceLevel it's off like the
web.config was ignored.

Any suggestions on how to correct this?
 
G

Guest

Just the generic "i dont like your web.config" error.

Configuration Error
Description: An error occurred during the processing of a configuration file
required to service this request. Please review the specific error details
below and modify your configuration file appropriately.

Parser Error Message: Exception in configuration section handler.

Source Error:

Line 16: <add key="LogDirectoryName" value="\logs" />
Line 17: </appSettings>
Line 18: <system.diagnostics>
Line 19: <switches>
Line 20: <add name="MyTraceSwitch" value="4" />
 
G

Guest

I am new in .NET but I am currently at a chapter on Debugging and in the
example the TraceSwitch variable is declared as static, i.e.

static TraceSwitch MyTraceSwitch = new TraceSwitch("MyTraceSwitch", "My Web
Service");

The book is on Windows based applications and so this may not be of any help
but thought I would make the suggestion anyway.
 

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

Members online

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top