WCF Tracing switchvalue is Off yet there is still a trace output being generated

那年仲夏 提交于 2020-01-12 05:38:05

问题


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?


回答1:


switchValue="Off" will only control System.ServiceModel. It does not control the System.ServiceModel.MessageLogging

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>

.NET framework for Configuring Message Logging

The logging level, as well as the additional options, are discussed in the Logging Level and Options section.

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.

Copy

 <source name="System.ServiceModel.MessageLogging" switchValue="Verbose">

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.



来源:https://stackoverflow.com/questions/13411221/wcf-tracing-switchvalue-is-off-yet-there-is-still-a-trace-output-being-generated

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!