Showing posts with label Debugging. Show all posts
Showing posts with label Debugging. Show all posts

Saturday, May 31, 2014

Logging in WCF

Have you ever wondered how to log messages sent to a WCF service? I had an iPhone app not being able to connect to a method in a WCF service, so I did this to enable logging of requests:

  <diagnostics>
    <messageLogging
         logEntireMessage="true"
         logMalformedMessages="true"
         logMessagesAtServiceLevel="true"
         logMessagesAtTransportLevel="false"
         maxMessagesToLog="3000"
         maxSizeOfMessageToLog="2000"/>
  </diagnostics>
  </system.serviceModel>
<system.diagnostics>
  <sources>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
                 <add name="messages"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="c:\logs\messages.svclog" />
          </listeners>
      </source>
    </sources>

</system.diagnostics>

Then once you have a log file, open it with SvcTraceViewer.exe, the Service Trace Viewer tool from Microsoft.