Dynamics CRM in the Field

Information from the Microsoft Dynamics CRM PFE team working in the field

How to Enable WCF Tracing for the CRM 2011 Outlook Client

How to Enable WCF Tracing for the CRM 2011 Outlook Client

Rate This
  • Comments 1

Recently I was working with a customer on some CRM 2011 Outlook client performance issues where I needed to inspect the data sent between the client and server. With CRM 4.0 I would use Fiddler to capture traffic to/from the client and server to see exactly what was happening. The CRM 2011 Outlook client now uses WCF to request data from the CRM server. If you ever view the WCF traffic in fiddler or Netmon you will notice the request/response data is no longer in a readable format. In order to get details of the request/response you will need to use WCF tracing on the client machine. Below are the steps to enable and view the WCF tracing.

1. Create a folder directly on the c: drive called “log”. The name and location doesn’t matter as long as it matches the path provided in the config file.

2. Navigate to “C:\Program Files (x86)\Microsoft Dynamics CRM\Client\” and open the “client{guid}.config” file in a text editor such as notepad.

3. Insert the following block of XML in the <Configuration> section of the CONFIG file. This XML will specify the WCF trace levels, trace name and location.

<system.diagnostics>
    <sources>
      <source name ="System.ServiceModel.MessageLogging"
              switchValue="Verbose, ActivityTracing">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="xml" type="System.Diagnostics.XmlWriterTraceListener"
           traceOutputOptions="LogicalOperationStack"
           initializeData="C:\log\CRMTrace.svclog" />
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>
  <system.serviceModel>
    <diagnostics>
      <messageLogging
           logEntireMessage="true"
           logMalformedMessages="false"
           logMessagesAtServiceLevel="true"
           logMessagesAtTransportLevel="false"/>
    </diagnostics>
  </system.serviceModel>

4. Save and close the CONFIG file.

5. Launch Outlook and you will see a trace file called CRMTrace.svclog will be created in the log folder you had created in step 1. All WCF traffic to the server will be logged while the client is running.

 

Viewing the WCF Traces

Once you have collected the trace it can be viewed using the SvcTraceViewer.exe utility which is only available in the .Net SDK. The SDK is an ISO file and can be downloaded at the following location.

http://www.microsoft.com/download/en/details.aspx?DisplayLang=en&id=11310

The SDK contains a lot of stuff, but if you just want the viewer you can select “Developer Tools \ .NET Development Tools” during the setup. The SvcTraceViewer.exe utility will then be located at C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin

To make this a little easier to find I have uploaded a copy of the SvcTraceViewer.exe to the following location.

Download SVCTraceViewer.exe

1. Launch the SvcTraceViewer.exe utility and choose file – Open.  Select the trace file and choose Open.

2. Once the trace is opened you can click on the Message tab and choose specific messages to see the details. The details can be viewed in a formatted view or raw XML.  In the following screenshots you will notice the WhoAmI request/Response, each showing up as a separate message.

image

image

 

Each request/response message pair will have a urn:UID that identifies them.  This guid can be found in fiddler or netmon since it shows up as plain text in the WCF header. You can then match up the fiddler/netmon data to that in the WCF trace by searching on this guid as shown below. The combination of Fiddler and WCF tracing is very helpful with performance work. Using Fiddler you can identify large/long running requests and then use WCF tracing to get details of what the request is doing.

Capture

image 

 

For more information about tracing and using the tool you can refer to the following MSDN article.

http://msdn.microsoft.com/en-us/library/ms732023.aspx

 

Jeremy Morlock

Microsoft Premier Field Engineer

  • Naturally the approach works for any client type talking SOAP. For example I'm using it to trace BizTalk WCF-custom adapter chatting with CRM service.  Just one needs to add diagnostic sections into BTSNTSvc.exe.config.  Thanks for the post!

Page 1 of 1 (1 items)
Leave a Comment
  • Please add 2 and 5 and type the answer here:
  • Post