Tracing Suggestion

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

Hello,

I have a web application where I am doing alot of the work in a separate
namespace that isn't part of a web page. I would like to be able to trace
into this section of code, but because it's not a 'Page' object the
Page.Trace isn't doable. Does anyone have any suggestions as to how I can
implement tracing in this separate code? Writing to an output file isn't
doable either because our customers will not allow write access to the disk
drive. Any suggestions? Thanks!
 
Richard,

You can access the trace yourself. Basically, set a reference to
System.Web.dll, and use the HttpContext class. The static property Current
will give you the current context, and then you can access the Trace
property on that to write to it.

Of course, your app should do nothing if the context is null (in the way
of tracing).

Hope this helps.
 
Thanks Nicholas, that worked perfectly!

Nicholas Paldino said:
Richard,

You can access the trace yourself. Basically, set a reference to
System.Web.dll, and use the HttpContext class. The static property Current
will give you the current context, and then you can access the Trace
property on that to write to it.

Of course, your app should do nothing if the context is null (in the way
of tracing).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Richard said:
Hello,

I have a web application where I am doing alot of the work in a separate
namespace that isn't part of a web page. I would like to be able to trace
into this section of code, but because it's not a 'Page' object the
Page.Trace isn't doable. Does anyone have any suggestions as to how I can
implement tracing in this separate code? Writing to an output file isn't
doable either because our customers will not allow write access to the
disk
drive. Any suggestions? Thanks!
 
Back
Top