Enabling Service Diagnostics

7. March 2007 07:51

At some point in the development cycle, the inevitable necessity of debugging your application will arise.  For WCF services, special support is available for capturing diagnostic data concerning your service and its exchanging of messages with clients.  There is a handy utility that ships with the Windows SDK for Vista and .NET Framework 3.0 for viewing the diagnostic output.  It is known as the Service Trace Viewer.

Before you can view the diagnostic output in the viewer, the service must be configured to capture the diagnostic data.  This is accomplished by making some entries in your service configuration file.  Personally, I prefer to take the easy approach and use the Service Configuration Editor.

Once your service configuration has been loaded into the editor, select the Diagnostics folder.  You will find there are a few different types of diagnostics ranging from performance counters to logging.  I recommend playing around with all of them to get a feel for what they can do.  However, I am going to focus on message logging and tracing over the next couple of blog posts.

Notice there is a link to enable each type of diagnostic.  It doesn't get much simpler than that.  With a single click, your diagnostic of choice can be turned on or off.  When enabling message logging and/or tracing, the configuration editor handles setting up the listener for receiving diagnostics and the source used to store the output.  There are quite a few settings available for each one.  For example, message logging can be configured to record messages at the transport level (as they appear on the wire) or the service level (prior to packaging for transport).  For tracing, it is possible to set options such as the trace level for controlling the amount of information that is captured. 

Be sure to take a look at your app.config before and after saving the configuration changes.  It should be rather obvious how much xml the editor saves your from writing by hand.

Later this week, I will go over some of the capabilities of the Service Trace Viewer by examining some diagnostic output from a service.

Comments are closed

About Me

I'm a passionate software developer and advocate of the Microsoft .NET platform.  In my opinion, software development is a craft that necessitates a conscious effort to continually improve your skills rather than falling into the trap of complacency.  I was also awarded as a Microsoft MVP in Connected Systems in 2008, 2009, and 2010.

Can’t code withoutThe best C# & VB.NET refactoring plugin for Visual Studio
Follow jeff_barnes on Twitter

View Jeff Barnes's profile on LinkedIn


Shared Items


Anything you read or see on this site is solely based on my own thoughts.  The material on this site does not necessarily reflect the views of my employer or anyone else.  In other words, I don't speak for anyone other than myself.  So, don't assume I am the official spokesperson for anyone.