WCF provides a number of diagnostics features that can help you troubleshoot your applications. We will look at two of these: message logging and tracing.
Both of these output to the .svclog
files that you can analyze using the Service Configuration Editor.
For this demonstration, we will use the Service Configuration Editor that is part of the Windows SDK. For more information, visit the Configuration Editor Tool (SvcConfigEditor.exe) page on MSDN at http://msdn.microsoft.com/en-us/library/ms732009(v=vs.100).aspx.
Message logging and tracing are both configured in the same place, so you will configure them both at the same time. To do this, modify the configuration file of the AOS by performing the following steps:
bin
directory of your AOS, for example, C:Program FilesMicrosoft Dynamics AX60ServerAX60inAx32Serv.exe.config
.The result should look like the following screenshot:
As you can see, both message logging and tracing are now active. What this did was add the following nodes to the configuration file:
<system.diagnostics> <sources> <source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing"> <listeners> <add type="System.Diagnostics.DefaultTraceListener" name="Default"> <filter type="" /> </add> <add name="ServiceModelTraceListener"> <filter type="" /> </add> </listeners> </source> <source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing"> <listeners> <add type="System.Diagnostics.DefaultTraceListener" name="Default"> <filter type="" /> </add> <add name="ServiceModelMessageLoggingListener"> <filter type="" /> </add> </listeners> </source> </sources> <sharedListeners> <add initializeData="C:Program FilesMicrosoft Dynamics AX60ServerAX60inAx32Serv_messages.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp"> <filter type="" /> </add> <add initializeData="C:Program FilesMicrosoft Dynamics AX60ServerAX60inAx32Serv_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp"> <filter type="" /> </add> </sharedListeners> <switches> <add name="ServiceTraceLevel" value="Off" /> </switches> <trace autoflush="false" indentsize="4"> <listeners> <add initializeData="Dynamics AX Services" type="System.Diagnostics.EventLogTraceListener" name="AxTraceListener"> <filter type="" /> </add> </listeners> </trace> </system.diagnostics>
Before you can take a look at the trace files, you first have to make sure to generate some service communication. In order to do this, execute the getAllTitles service operation of CVRTitleService as you have done many times in this chapter.
The WCF trace file containing the message logging is located in the bin
directory of the AOS where tracing has been enabled. The name of the file is Ax32Serv_messages.svclog
. Double-click on it and it will open using the Microsoft Service Trace Viewer, as shown in the following screenshot:
As you can see from the previous screenshot, the message that corresponds to the reply that the AOS sent to the .NET application has been selected. You can see the header and also the data of the message because we already set the LogEntireMessage property to True.
The WCF trace file containing the tracing data is located in the bin
directory of the AOS where the tracing has been enabled. The name of the file is Ax32Serv_tracing.svclog
. Double-click on it and it will open using the Microsoft Service Trace Viewer, as shown in the following screenshot:
While message logging gives emphasis to the content of the messages, tracing focuses more on the events that occur and the correlation between them. When combined with a trace from the client side, it allows you to trace WCF from end to end.
There is much more to WCF message logging and tracing than we can cover here. For an in-depth view on how to configure it the best for your implementation, visit the Diagnostic Tracing and Message Logging page on MSDN at http://msdn.microsoft.com/en-us/library/dd788183.aspx.
3.145.11.227