System.Diagnostics.Trace和TraceContext有什么区别 [英] What is difference between System.Diagnostics.Trace and TraceContext

查看:184
本文介绍了System.Diagnostics.Trace和TraceContext有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,
我已经搜索了论坛MSdn的网络站点,但无法在System.Diagnostics.Trace和TraceContext中获得确切的区别.

我在我的应用程序中尝试了以下代码:

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");



并且在web.config的页面级别和应用程序级别启用跟踪.

但是当我看到输出时,我仅从trace.axd中的第一行获得输出.
但是当我看到调试器时,我可以看到两个输出.

谢谢,
Jitendra



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

推荐答案

嗨Jitendra,

虽然您可以对大多数任何.NET应用程序使用System.Diagnostics.Trace,但System.Web.TraceContext仅用于Web应用程序.第二个当然依赖于System.Web,因此您不会在其他地方使用它.

只有TraceContext知道HTTP上下文,因此,在启用页面级(或Webapp级)跟踪时,它将输出到浏览器.

干杯!
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!


这篇关于System.Diagnostics.Trace和TraceContext有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆