问题描述
追查.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?
有一个微软的家伙做了benchmarks不同听众的开销的:
A Microsoft guy did benchmarks of the overhead with different listeners:
Default |===============================14,196 ms=====/ /================>
TextWriterTraceListener |=========211 ms======>
EventProviderTraceListener |=> 77ms
什么是默认
跟踪监听器,为什么它这么慢?它是<$c$c>OutputDebugString$c$c>?是<$c$c>OutputDebugString$c$c>真正的两个数量级的比写入文件慢?
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 <$c$c>TraceListener$c$c>只是用<$c$c>OutputDebugString$c$c>?
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的运行并不清楚,但<$c$c>DefaultTraceListener$c$c>被记录是这样的:
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。
因此,如果 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;监听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!