Skip to content

Instantly share code, notes, and snippets.

@mrichman
Last active January 27, 2023 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrichman/9911daba9f7b4d799b4e21a7fbb5060f to your computer and use it in GitHub Desktop.
Save mrichman/9911daba9f7b4d799b4e21a7fbb5060f to your computer and use it in GitHub Desktop.
Enable WCF Service Trace Logging - view with SvcTraceViwer.exe (i.e. C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- ... -->
<system.serviceModel>
<!-- ... -->
<diagnostics wmiProviderEnabled="true">
<messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" />
</diagnostics>
</system.serviceModel>
<!-- ... -->
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="myUserTraceSource" switchValue="Information, ActivityTracing">
<listeners>
<add name="xml"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\logs\Traces.svclog" />
</sharedListeners>
</system.diagnostics>
</configuration>
@pjt33
Copy link

pjt33 commented Jan 27, 2023

Thank you. The <system.serviceModel><diagnostics><messageLogging> element is inexplicably not mentioned by the official documentation, and it's a nasty gotcha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment