Levels of Tracing, Part 3
Although often associated with event tracing, message logging is actually a separate facility from the standard levels of tracing. Message logging is not enabled by default just like event tracing is not enabled by default. You activate message logging by adding a trace source and listener to the configuration file as we saw last time. The first difference is that the trace source you need to add is System.ServiceModel.MessageLogging instead of the System.ServiceModel trace source that we were using for event tracing.
I've done the minimal changes to the previous example to show how message logging is enabled.
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add initializeData="c:\messagelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener"
name="messagelog">
</add>
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
The second difference is that the System.SerivceModel.MessageLogging trace source ignores all of those different trace levels that we talked about. If you provide a trace level to this trace source, then it has no effect. Instead, there is a separate configuration section specifically for message logging.
<configuration>
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true"
logMalformedMessages="false"
logMessagesAtServiceLevel="false"
logMessagesAtTransportLevel="true"
maxMessagesToLog="100"
maxSizeOfMessageToLog="65536"/>
</diagnostics>
</system.serviceModel>
</configuration>
Next time I'll do a rundown of these options and some recommended settings for message logging.
Comments
Anonymous
May 11, 2009
Hi, I have a problem that I'd like to solve, but I don't know how to configure end-to-end logging. I have three applications (A, B, C) that use WCF service through NetMsmqBinding to communicate with each other. A is the host, and B and C are clients of the WCF service. The service uses message security with certificates. The communication between B and A works perfectly OK, though, the communication between C and A does not. So I'd like to use logging and figure out why the messages are deleted from the queue (in the case C -> A) and are not processed by the host... How do we configure logging for this scenario in order to diagnose the problem... (app B and app C are on the same machine, app A is on different machine). Thanks!Anonymous
May 12, 2009
Hi Pavel, You probably want to start with ActivityTracing from part 2 of this series and see if anyone is hitting an error that would throw the message away. That should be enough information to correlate things without needing to see the actual messages (unless you think it's something about the message format that is causing things to go wrong). Also, use the MMC for MSMQ to check if the messages are being poisoned or dropped by the queue itself.Anonymous
May 17, 2009
Today's article continues the series on tracing and message logging with a look at the different message