Tracing Execution in Class Library

  • Thread starter Thread starter Graham Cottle
  • Start date Start date
G

Graham Cottle

I have an ASP.NET and a Windows Forms Application which both use a shared
class library.

Is there a way which I can use the Trace Object in the class library so that
I can get Trace Output sent to Trace.AXD when using it with the ASP.NET
Application?

I have inserted a number of Trace Statements, but they send output to the
Visual Studio output window instead of the Trace.AXD output. If I put a
Trace statement in a Web Page then I can get the output where I want it.

I guess I need to use the System.Web.Trace object rather than the
System.Diagnostics.Trace, but this needs an HTTPContext, which I cannot see
how to get. I also don;t want to break compatibility with the Windows Forms
application.

Am I heading in the right direction?

Thanks
Graham Cottle
 
if you know the file you wish to write to, why stick to the trace class?

you could do something like

LogTrace ( string szMyString )
{
StreamWriter wrter = File.AppendText ( "myOutputFile.txt" );
wrter.WriteText ( szMyString );
wrter.Flush();
wrter.Close;
}

then call this function from where ever you want and you're doing
essentially the same thing.

hope that helps.

Daniel.


I have an ASP.NET and a Windows Forms Application which both use a shared
class library.

Is there a way which I can use the Trace Object in the class library so that
I can get Trace Output sent to Trace.AXD when using it with the ASP.NET
Application?

I have inserted a number of Trace Statements, but they send output to the
Visual Studio output window instead of the Trace.AXD output. If I put a
Trace statement in a Web Page then I can get the output where I want it.

I guess I need to use the System.Web.Trace object rather than the
System.Diagnostics.Trace, but this needs an HTTPContext, which I cannot see
how to get. I also don;t want to break compatibility with the Windows Forms
application.

Am I heading in the right direction?

Thanks
Graham Cottle
 
Back
Top