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"
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.