WCF Tracing – Easy WCF
Skip to content

WCF Tracing

You can use Microsoft service Configuration Editor to enable tracing and message logging in WCF.

You can enable it in 2 ways.

  • Right click on web.config–>Edit WCF Configuration
  • Go to Tools in Visual studio–>WCF Service Configuration Editor–>File–>open–>open the required config file from local machine

After the tool is open, here is the steps to enable Logging.

  • Go to Diagonostics
  • Enable Log Auto Flush
  • Enable Message Logging

Enable Tracing:

Step 1. Configuring WCF to trace information/Define Trace Source

We have the following options:

  • System.ServiceModel
  • System.ServiceModel.MessageLogging
  • System.ServiceModel.IdentityModel
  • System.ServiceModel.Activation
  • System.Runtime.Serialization
  • System.IO.Log
  • Cardspace

In configuration file, we will define a source to enable this configuration as follows:

     

Step 2. Setting Tracing Level

We have the following available options, we need to set this tracing level to available options other than default “Off”:

  • Off
  • Critical
  • Error
  • Warning
  • Information
  • Verbose
  • ActivityTracing
  • All
In configuration file, we can choose above values for switchValue attribute as follows:

Step 3. Configuring a trace listener

For configuring a trace listener, we will add following to config file.

Step 4. Enabling message logging

logEntireMessage: By default, only the message header is logged but if we set it to true, entire message including message header as well as body will be logged.
logMalformedMessages: this option log messages those are rejected by WCF stack at any stage are known as malformed messages.
logMessagesAtServiceLevel: messages those are about to enter or leave user code.
logMessagesAtTransportLevel: messages those are about to encode or decode.
maxMessagesToLog: maximum quota for messages. Default value is 10000.
maxSizeOfMessageToLog: message size in bytes.

Putting all this together, configuration file will appear like this.

© 2015, admin. All rights reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *