.NET中的每个跟踪示例都会删除" Default"侦听器:
<configuration>
<system.diagnostics>
<sources>
<source name="TraceSourceApp" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="ConsoleListener"/>
<add name="ETWListener"/>
<remove name="Default"/>
</listeners>
Run Code Online (Sandbox Code Playgroud)
什么是默认侦听器,为什么默认情况下会出现?
Default |===============================14,196 ms=====/ /================>
TextWriterTraceListener |=========211 ms======>
EventProviderTraceListener |=> 77ms
Run Code Online (Sandbox Code Playgroud)
什么是Default跟踪侦听器,为什么它如此慢?是OutputDebugString吗?是OutputDebugString真是两个数量级比写入文件慢?
是否有一个TraceListener只使用的.NET OutputDebugString?
什么是默认的跟踪侦听器,为什么它如此缓慢,为什么它通常被删除,如果它是如此糟糕为什么它是默认值?
Jon*_*eet 11
从该博客文章中不清楚代码是如何运行的,但是DefaultTraceListener记录如下:
默认情况下,Write和WriteLine方法将消息发送到Win32 OutputDebugString函数和Debugger.Log方法.有关OutputDebugString函数的信息,请参阅Platform SDK或MSDN.
因此,如果Debugger.Log实际打印到UI窗口(并且很可能滚动它等),我可以看到导致大量减速.