WCF – Trace Log

While developing BizTalk projects that interact between WCF services, solution of the problem sometimes can be WCF service side. After constructing integration BizTalk and WCF service generally we need to know which message taken by service or what the structure of message is. The message which is sent by BizTalk can be seen using with Administration Console. But what about the message is taken by WCF service. At this point monitoring and tracing of service becomes very important to get runtime information of service.

1. Quick trace

Use the following config in your service config file. The service will log all requests and responses into the messages.svclog file. This file can be opened by service trace viewer tool. You can find more information about tool this link

<system.diagnostics>
 <sources>
 <source name="System.ServiceModel.MessageLogging">
 <listeners>
 <add name="messages"
 type="System.Diagnostics.XmlWriterTraceListener"
 initializeData="c:\logs\messages.svclog">
 </add>
 </listeners>
 </source>
 </sources>
 </system.diagnostics>

<system.serviceModel>

<diagnostics>
 <messageLogging
 logEntireMessage="true"
 logMalformedMessages="true"
 logMessagesAtServiceLevel="true"
 logMessagesAtTransportLevel="true"
 maxMessagesToLog="3000"
 maxSizeOfMessageToLog="2000">
 </messageLogging>
 </diagnostics>

<system.serviceModel>

2. Appfabric trace

Appfabric is great extension of IIS in order to manage and monitor services deployed in IIS. The services shoul be compiled .NET 4.0 or above otherwise Appfabric can’t watch services.
11
Have a look at “Configure WCF and WF for Application” screen, Monitoring section provides ability to write events to database. It also has diagnostic tracing and message logging subsection.
Select WCF tracing level, enter trace file name also enable message logging, enter file name.

22

PS: After sending requests which required to be logged, application pool of service should be stopped for producing svclogfile.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s