WCF 跟踪开关值已关闭,但仍有跟踪输出正在生成 [英] WCF Tracing switchvalue is Off yet there is still a trace output being generated
问题描述
在打开 WCF 跟踪以帮助查找问题后,我现在希望关闭跟踪.所以我把我的配置文件改成了这个...
After having turned on WCF Tracing to assist with finding a problem, I now wish to turn off tracing. So I have changed my config file to this...
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Off" >
<!-- Information,ActivityTracing-->
<listeners>
<add name="xmlTraceListener" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Off" >
<listeners>
<add name="xmlTraceListener" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xmlTraceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="C:\WCFLogs\DataPortalTrace.svclog" />
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
但是仍然有跟踪输出被发送到指定的输出文件.这是为什么?我错过了什么?
Yet there is still trace output being send to the indicated output file. Why is that? What am I missing?
推荐答案
switchValue="Off"
只会控制 System.ServiceModel
.它不控制 System.ServiceModel.MessageLogging
switchValue="Off"
will only control System.ServiceModel
. It does not control the System.ServiceModel.MessageLogging
据我所知,您可以通过 maxMessagesToLog="0"
进行控制——您可能已经在
标签;
As of my knowledge you can control via maxMessagesToLog="0"
– you might have already <diagnostics>
tag under <system.serviceModel>
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="0"
/>
</diagnostics>
日志级别和其他选项在日志级别和选项部分讨论.
The logging level, as well as the additional options, are discussed in the Logging Level and Options section.
源的 switchValue
属性仅对跟踪有效.如果按如下所示为 System.ServiceModel.MessageLogging
跟踪源指定 switchValue 属性,则它不起作用.
The switchValue
attribute of a source is only valid for tracing. If you specify a switchValue attribute for the System.ServiceModel.MessageLogging
trace source as follows, it has no effect.
复制
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
如果要禁用跟踪源,则应改用 messageLogging 元素的 logMessagesAtServiceLevel
、logMalformedMessages
和 logMessagesAtTransportLevel
属性.您应该将所有这些属性设置为 false.这可以通过使用前面代码示例中的配置文件、通过配置编辑器 UI 界面或使用 WMI 来完成.有关配置编辑器工具的详细信息,请参阅配置编辑器工具 (SvcConfigEditor.exe).有关 WMI 的详细信息,请参阅使用 Windows Management Instrumentation 进行诊断.
If you want to disable the trace source, you should use the logMessagesAtServiceLevel
, logMalformedMessages
, and logMessagesAtTransportLevel
attributes of the messageLogging element instead. You should set all these attributes to false. This can be done by using the configuration file in the previous code example, through the Configuration Editor UI interface, or using WMI. For more information about the Configuration Editor tool, see Configuration Editor Tool (SvcConfigEditor.exe). For more information about WMI, see Using Windows Management Instrumentation for Diagnostics.
这篇关于WCF 跟踪开关值已关闭,但仍有跟踪输出正在生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!