The amount of traces generated by WCF (System.ServiceModel and System.ServiceModel.MessageLogging) can be overwhelming at first glance. The following is a collection of notes regarding WCF tracing. A more detailed description can be viewed at MSDN Service Trace Viewer.
These notes will be used against a trace of the WCF Simple Header created in an earlier post. The following shows how to turn on tracing on both the System.ServiceModel and System.ServiceModel.MessageLogging libraries.
1: <system.serviceModel>
2: ...
3: <diagnostics>
4: <messageLogging maxMessagesToLog="100"
5: logEntireMessage="true"
6: logMessagesAtServiceLevel="true"
7: logMalformedMessages="true"
8: logMessagesAtTransportLevel="true">
9: </messageLogging>
10: </diagnostics>
11: </system.serviceModel>
12: <system.diagnostics>
13: <sources>
14: <source name="System.ServiceModel" switchValue="Information, ActivityTracing"
15: propagateActivity="true">
16: <listeners>
17: <add name="xml" />
18: </listeners>
19: </source>
20: <source name="System.ServiceModel.MessageLogging" switchValue="Information">
21: <listeners>
22: <add name="xml" />
23: </listeners>
24: </source>
25: </sources>
26: <sharedListeners>
27: <add name="xml"
28: type="System.Diagnostics.XmlWriterTraceListener"
29: initializeData="HostTraces.svclog" />
30: </sharedListeners>
31: <trace autoflush="true" />
32: </system.diagnostics>
In the above configuration, the switchValues of the sources are currently sent to Information (and ActivityTracing for ServiceModel). These can be adjusted depending on the requirements. For example, I have found setting System.ServiceModel to warning and System.ServiceModel.MessageLogging to Information to be a useful combination where communication is reliable, but the content of the messages being passed need to be available for review.
Service Viewer Filter Options
Filter options can be set to hide/show trace messages within the viewer easily (Ctrl-F2 or View/Filter Options...).
In the situation where you would like to only show the messages being submitted and returned, you could set the only the Show WCF ServiceModel traces (i.e., all other checkboxes are not checked). Of course, this is only true if you have MessageLogging tracing at Information Level.
Filter Tool Bar
The Filter Tool Bar has several options to help narrow down the number of messages.
Find Tool Bar
As you would expect, the Find Tool Bar will allow a text search across the traces specified.
Custom Filtering
Another very powerful feature of the SvcTraceViewer. This will allow you to create filters tailored to your particular application. Another benefit of the the custom filter dialog is it allows a quick way of generating the xpath queries (useful when integrating BAM).
Summary
I'll keep this post brief as the MSDN description of the trace viewer is very good and covers most of the features in sufficient detail to get started.
Posted
Thu, Sep 6 2007 9:56 AM
by
chilberto