Enable WCF trace logging

To point down problems in WCF, you can enable tracing. The WCF listeners produce valuable information to trace down errors. You can see the incomming and outgoing traffic. By default, tracing is off. To enable it, simply add the folowing section to the app.config file of your application you’re trying to debug:

            <source name="System.ServiceModel" 
                    switchValue="Information, ActivityTracing"
               <add name="traceListener" 
                   initializeData= "c:\log\Traces.svclog" />

When you run your application and WCF is used, a file “traces.svclog” is created on “c:\log”. Be sure you have rights to write to the defined location. With the use of the “Microsoft Service Trace Viewer”, which is a part of the Visual Studio suite, you can view the created file. Since this viewer is asociated by default to files of the svclog-type, you can double click on the log file to open it in the WCF viewer.

Posted in C#, Debugging, WCF at August 29th, 2012. No Comments.