Message Logging in WCF

Filed under Logging, WCF

Last week I gave an intro session on WCF at the Columbia .NET User Group. One topic of interest seemed to be message logging. There was one person who asked specifically about logging calls made between a WCF service and an ASP.NET client. Here are two tools I would suggest using: Fiddler, the simpler of the two and a free download, and the Service Trace Viewer which comes installed with Visual Studio 2008.

Fiddler could be used in the scenario mentioned above. It’s easy to learn and there are training videos posted on the Fiddler site. However it only logs http traffic.

The Service Trace Viewer has a steeper learning curve but it allows you to log messages sent over tcp as well as http. The data returned in the trace can be pretty overwhelming; I recommend fine-tuning the trace options till you get back only the data you need. One point where you will want to modify the configuration for your specific situation is in the ServiceModel.Diagnostics section: see the sample below. Here’s a good MSDN link on proper configuration for diffrent scenarios.


    <diagnostics performanceCounters="All" wmiProviderEnabled="true">

      <messageLogging logEntireMessage="true"





                      maxSizeOfMessageToLog="100000" />



Included in this post is a solution with very simple service and client projects. It provides a good starting point for understanding how to configure diagnostic tracing in your WCF services.The app.config files in both are set to output .svclog files to the same folder as the solution file.

Simple Logging Example