Saturday, November 8, 2008

Tracing WCF messages on a Windows Server

If you use WCF for communication, you'll need to do quite a bit of debugging if you ever want to get to the bottom of serialization issues. Microsoft has thankfully provided a responsible tracing application which is installed with the SDK.

The Service Trace Viewer tool reads the default log file produced from the Server. To get this to be produced by your WCF Server simply add the following section to your web.config file.




switchValue="Information, ActivityTracing"
propagateActivity="true">

type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "SdrConfigExample.e2e" />






This will produce a file in the root directory called SdrConfigExample.e2e. Start the Trace Viewer by clicking on the SvcTraceViewer.exe which is probably located in the default installation area C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin. Click File/Open and select the SdrConfigExample.e2e file, you'll probably have to select the "All Files (*.*)" option.
As soon as this is opened you should see all the messages which have been sent.