Diagnostic and Tracing WCF Service Host and Client

In this exercise we will configure a configuration file for diagnostics. When you install VS2008, you get the Windows SDK 6.0A installed. This includes a "Service Configuration Editor" to edit the configuration for diagnostics and a "Service Trace Viewer" for tracing as below:

Diagnostic-and-Tracing-WCF-service-Host-and-Client-1.jpg
 
Task 1: Start the Service Configuration Editor and open the "App.Config" file of the host application.
 
Task 2: Select Messaging Logging from the Diagnostic, and from the "General" set "LogEntireMessage" to "True" as below:

Diagnostic-and-Tracing-WCF-service-Host-and-Client-2.jpg

Task 3: Select "Diagnostic" from the "Configuration" Pane and from the "Disgnostic" panel, enable "Log Auto Flush", enable "Message Logging", enable Tracing to "Information" as below:

Diagnostic-and-Tracing-WCF-service-Host-and-Client-3.jpg

Task 4: Expand "Listeners" from the "Configuration", you will have "ServiceModelTraceListener" and "ServiceModelMessageLoggingListener" files generated. You will find "App_TraceLog.svclog" and "App_Message.svclog" as below:

Diagnostic-and-Tracing-WCF-service-Host-and-Client-4.jpg

Save the changes and repeat the tasks above for the App.Config file of the client application.
 
Task 5: Now run the WCF Host and Client application and click on the "Add" and "Get Data" buttons.
 
Task 6: Open the "Service Trace Viewer" and open both the "TraceLog" and "Messagelog" file from the host application, you will get the following result:

Diagnostic-and-Tracing-WCF-service-Host-and-Client-5.jpg

Select the "Message" Tab, select any message and for that message select "XML", you will find values in plain text format.


Similar Articles