Tracing Execution in Class Library

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
 
D

Daniel Bass

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
 

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

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top