Friday, March 16, 2012

Tracing WCF Calls

I ran into an issue with one of my WCF services and was having the quite a time trying to track it down, especially since it was failing before it was getting to the actual service.  I came across a nice way of tracing the call all the way through the process.  Add the following section to your web.config file:

<system.diagnostics>
  <sources>
    <source name="System.ServiceModel"
            switchValue="Information, ActivityTracing"
            propagateActivity="true">
      <listeners>
        <add name="traceListener"
            type="System.Diagnostics.XmlWriterTraceListener"
            initializeData= "C:\Logs\Traces.svclog" />
      </listeners>
    </source>
  </sources>
</system.diagnostics>

This will create a trace file that you can open up in the Microsoft Service Trace Viewer.  You can read about the details here.

Quick note – Don’t forget to remove it when you’re done!

No comments:

Post a Comment