.NET跟踪:什么是"默认"监听器? [英] .NET Tracing: What is the "Default" listener?

查看:190
本文介绍了.NET跟踪:什么是"默认"监听器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

追查.NET人的每一个例子删除默认监听器:

Every example of tracing in .NET people remove the "Default" listener:

<configuration>
  <system.diagnostics>
    <sources>
      <source name="TraceSourceApp" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch">
        <listeners>
          <add name="ConsoleListener"/>
          <add name="ETWListener"/>
          <remove name="Default"/>
        </listeners>

什么是默认监听器,为什么它有默认?

What is the Default listener, and why is it there by default?

有一个微软的家伙做了<一href="http://blogs.msdn.com/b/peaceofmind/archive/2008/04/16/using-eventprovidertracelistener.aspx">benchmarks不同听众的开销的:

A Microsoft guy did benchmarks of the overhead with different listeners:

Default                    |===============================14,196 ms=====/ /================> 
TextWriterTraceListener    |=========211 ms======>
EventProviderTraceListener |=> 77ms

什么是默认跟踪监听器,为什么它这么慢?它是<一个href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa363362%28v=vs.85%29.aspx"><$c$c>OutputDebugString?是<一个href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa363362%28v=vs.85%29.aspx"><$c$c>OutputDebugString真正的两个数量级的比写入文件慢?

What is the Default trace listener, and why is it so slow? Is it OutputDebugString? Is OutputDebugString really two orders of magnitude slower than writing to a file?

有一个.NET <一个href="http://msdn.microsoft.com/en-us/library/system.diagnostics.tracelistener.aspx"><$c$c>TraceListener只是用<一href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa363362%28v=vs.85%29.aspx"><$c$c>OutputDebugString?

Is there a .NET TraceListener that just uses OutputDebugString?

什么是的默认的跟踪监听器,它为什么这么慢,为什么会习惯上删除,如果它是如此糟糕,为什么它是默认的?

What is the default trace listener, why is it so slow, why is it customarily removed, and if it's so bad why is it the default?

推荐答案

这是从博客文章如何code的运行并不清楚,但<一个href="http://msdn.microsoft.com/en-us/library/system.diagnostics.defaulttracelistener.aspx"><$c$c>DefaultTraceListener被记录是这样的:

It's not clear from that blog post how the code was run, but the DefaultTraceListener is documented like this:

默认情况下,Write和WriteLine方法放出消息,在Win32 OutputDebugString的功能,并给Debugger.Log方法。有关的OutputDebugString功能的信息,请参阅平台SDK或MSDN。

By default, the Write and WriteLine methods emit the message to the Win32 OutputDebugString function and to the Debugger.Log method. For information about the OutputDebugString function, see the Platform SDK or MSDN.

因此​​,如果 Debugger.Log 实际上是打印到UI窗口(而且很有可能它的滚动等),我可以看到,造成大量的经济放缓。

So if Debugger.Log is actually printing to a UI window (and quite possibly scrolling it etc) I can see that causing a lot of the slowdown.

这篇关于.NET跟踪:什么是&QUOT;默认&QUOT;监听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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