This is the first part in a series of small exercises where I try out the diagnostics features in WCF (Indigo). The articles will cover the Logging, Tracing, Performance Counters and WMI features in WCF.
First out is logging. Logging is controlled by using the configuration file for the application. By default all logging is turned off but it can be enabled individually for transport level-, service level- and malformed messages.
The following is an example that enables all message logging:
The highlighted attributes are the key attributes to enable the logging feature. logEntireMessage is set to true in order to have the whole message logged. The default is to only log the message header. The next three entries enable logging at the various levels. Depending on the binding used (and its configuration) there may be quite a few messages logged for each invoked operation. Since WCE logs all messages processed that may include messages things such as policy and security negotiation. It would be interesting to see complete flows of what is happening during the client-server interactions, but that is a different story...
The log files written are named like this:
By default log files are written using a default trace listener, which will write the files at the following location:
If another location should be used then a trace listener must be added in the "system.diagnostics" section in the configuration file for the source name “IndigoMessageLogTraceSource”.
The configuration below will write log files to a specified point using the provided MessageWriterTraceListener class:
<add name="multifile" type="System.ServiceModel.Diagnostics.MessageWriterTraceListener, System.ServiceModel, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b77a5c561934e089"
The highlighted attribute sets the directory used for the message logging, in this case c:\logs\messages.
Unfortunately it seems like it is only possible to set the diagnostics configuration before the service is started. If the configuration is changed while the application is running it has no impact. This is of course a limitation that is going to be hard to deal with in a production environment. Hopefully there will be some more work done in this area before the v.1 release of WCF comes out the door.