Use Message Logging for Debugging Purposes

- J.D. Meier, Carlos Farre, Jason Taylor, Prashant Bansode, Steve Gregersen, Madhu Sundararajan, Rob Boucher

User message logging for debugging purposes. Message logging can be used to diagnosed application errors and performance problems. Message logging is not turned on by default, because logging is an expensive operation that can consume disk space and processing time. Turn on message logging by setting attributes on the <messagelogging> element in your configuration file and adding a trace listener to log the events to a file.

Important: Make sure you limit the number of messages that are written to disk for a particular service, as disk space could be limiting factor. When the message limit is reached, a trace at the Information level is produced and all message logging activities stop.

The following configuration code enables Message Logging by creating a ServiceModelMessageLoggingListener and System.ServiceModel.MessageLogging source:
   <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
     <add type="System.Diagnostics.DefaultTraceListener" name="Default">
      <filter type="" />
     <add name="ServiceModelMessageLoggingListener">
      <filter type="" />
   <add initializeData="c:\inetpub\wwwroot\WCFService\web_messages.svclog"
    type="System.Diagnostics.XmlWriterTraceListener, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
    <filter type="" />
   <messageLogging logEntireMessage="false" logMalformedMessages="true"
    logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="true" />

Additional Resources

Last edited Jun 12, 2008 at 7:43 PM by prashantbansode, version 1


No comments yet.