Tracing with web.config

  • Thread starter Thread starter Mitkip
  • Start date Start date
M

Mitkip

Hello,

I just want to know if it's possible to trace an application into a
dedicated EventLog by just adding a new tag in web.config. I don't to
have to create it by coding something like : ev as new
EventLog("MyEventLog").

How to do it ?

Thanks ;)
 
Yes, this is possible, but only for a web application that runs with
unrestricted CAS permissions (full trust). To do this, simply use the
writeToDiagnosticsTrace of the system.web\trace element
(http://msdn2.microsoft.com/en-us/library/6915t83k(VS.80).aspx) to specify
that the ASP.NET trace should be written to the System.Diagnostics trace.
You'll also need to configure trace listeners. See the "Routing All Tracing
Output to .NET Framework Tracing" section at
http://msdn2.microsoft.com/en-US/library/b0ectfxd(VS.80).aspx for an
example. Just watch out for the consequences of using
writeToDiagnosticsTrace--it copies trace entries to the diagnostics trace
rather than forwarding them as at least some of the documentation would seem
to indicate. (i.e.: The system.web\trace configuration element will still
dictate how the trace may be viewed via your application.)
 
Yes, the TraceContext to Trace copying only works in 2.0. AFAIK, for 1.1,
there is no configuration-only solution to writing from the TraceContext to
the event log.
 
Back
Top