Click here to Skip to main content
15,220,107 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi Friends,
I have searched the net, forum msdn sites but not able to get exact difference in System.Diagnostics.Trace and TraceContext.

I had tried below code in my application :

Trace.Write("This is Tracing");
System.Diagnostics.Trace.TraceError("Error in first applciation");


and tracing is enable at Page level and also at Application level in web.config.

But when i see output, i get output from first line only in trace.axd.
But when i see debugger, i can see both output.

Thanks,
Jitendra
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Hi Jitendra,

While you can use System.Diagnostics.Trace for most any .NET app, System.Web.TraceContext is used only for web apps. The second, of course, relies on System.Web, so you wouldn't use it elsewhere.

Only the TraceContext is aware of the HTTP Context and, therefore, will output to the browser when page-level (or webapp-level) tracing is enabled.

Cheers!
   
Comments
Jitendra Zaa 8-May-10 10:55am
   
Thanks Mr James..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100