Using Trace and Switches in ASP.NET

T

Thomas Koch

Hi there - I am developing a general library which allows programs to access
our server product.

I am using the System.Configuration.Trace and
System.Configuration.BooleanSwitch classes for logging at runtime in my
library. When developing a console/windows application a user simply has to
set up a few switches and a trace listener within the application config
file in order to enable logging in the library:

<system.diagnostics>
<switches>
<add name="RobotExecuter" value="1" />
</switches>

<trace autoflush="true" >
<listeners>
<add name="mylog"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="robosuite.log.txt" />
</listeners>
</trace>
</system.diagnostics>

Now I would very much like to do the same in an ASP.NET application, however
the schema for Web.config files do not allow me to insert a
<system.diagnostics> section. Also I have been unable to locate any
configuration section handler which handles the system.diagnostic section.

How do I do this in ASP.NET? Any help would be greatly appreciated.

Regards
Thomas Koch
 
N

Natty Gur

Hi,

You just need to put <system.diagnostics> tag directly under
<configuration> tag and not under <system.web> tag :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<trace autoflush="false" indentsize="4"/>
<assert assertuienabled="false" logfilename="c:\AssertLog.txt"/>
</system.diagnostics>

<system.web>


Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 
T

Thomas Koch

Thank you - that worked. I thought I'd tried that but I must have done some
other error. :)

Thomas
 

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,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top