TextWriterTraceListener

G

Guest

Hello,
I'm trying to insert TextWriterTraceListener to web.config file, but it
fails all the time. This is my web.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation defaultLanguage="c#" debug="true" />
<customErrors mode="RemoteOnly" />
<authentication mode="Windows" />
<authorization>
<allow users="*" />
</authorization>
<trace enabled="false" requestLimit="10" pageOutput="false"
traceMode="SortByTime" localOnly="true" />
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false" timeout="20" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener"
initializeData="myListener.txt" />
</listeners>
</trace>
</system.diagnostics>
</configuration>

In code behind I try to output something like this:
System.Diagnostics.Trace.WriteLine("Tracing...");

But all the time I get an error:

Parser Error Message: Exception in configuration section handler.

Source Error:

Line 13: <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
Line 14: </system.web>
Line 15: <system.diagnostics>
Line 16: <trace autoflush="true" indentsize="4">
Line 17: <listeners>
Source File: c:\inetpub\wwwroot\TraceListener\web.config Line: 15

Thank you for assistance.
 
E

Eliyahu Goldin

The concept of tracing in ASP.NET is very different from that in Windows
..NET applications. Tracing in ASP.NET outputs trace information to the
client's browser. System.Diagnostics listeners don't work in ASP.NET. (At
least this is my experience. Will be happy to hear if someone can
demonstrate opposite).

Eliyahu
 
G

Guest

In this section here,
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener"
initializeData="myListener.txt" />

I thought the type attribute suppose to have the format of
type="[Class Name] , [Assembly Name]"

look in your machine.config file and you will see alot of examples of custom
section handlers
 
S

Sean Feldman

Hi,
thatnks, but this didn't help.
I get an exception when web.config is parsed at line that contains
<system.diagnostics>
Can't figure out why. I didn't implement any custom listener, just added
TextWriterTraceListener.
Weird.

Sean.
 
S

Sean Feldman

System.Diagnostics listeners work in ASP.Net.
It was demonstrated by Alik Levin (Microsoft IL) during the last conference.
Unfortunately, I can't figure out why web.config parsering fails on reading
<system.diagnostics> part...

Sean
 
S

Sean Feldman

Hi,
somewhere I read that if you're using assemblies from system.dll, then you
don't have to write type="...". But still, this is not the problem.

Tampa .NET Koder said:
In this section here,
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener"
initializeData="myListener.txt" />

I thought the type attribute suppose to have the format of
type="[Class Name] , [Assembly Name]"

look in your machine.config file and you will see alot of examples of custom
section handlers

Eliyahu Goldin said:
The concept of tracing in ASP.NET is very different from that in Windows
..NET applications. Tracing in ASP.NET outputs trace information to the
client's browser. System.Diagnostics listeners don't work in ASP.NET. (At
least this is my experience. Will be happy to hear if someone can
demonstrate opposite).

Eliyahu

responseEncoding="utf-8"
/>
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top