1. Change the app.config/web.config of your application that calls the WCF service by adding System.diagnostics detail as below
- <system.diagnostics>
- <sources>
- <source name=“System.ServiceModel“ switchValue=“Verbose,ActivityTracing“ propagateActivity=“true“>
- <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=“Verbose,ActivityTracing“>
- <listeners>
- <add type=“System.Diagnostics.DefaultTraceListener” name=“Default“>
- <filter type=“” />
- </add>
- <add name=“ServiceModelMessageLoggingListener“>
- <filter type=“” />
- </add>
- </listeners>
- </source>
- </sources>
- <sharedListeners>
- <add initializeData=“MyWCFTraceLog.svclog“
- type=“System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089“
- name=“ServiceModelTraceListener” traceOutputOptions=“Timestamp“>
- <filter type=“” />
- </add>
- <add initializeData=“MyWCFTraceLog.svclog“
- type=“System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089“
- name=“ServiceModelMessageLoggingListener” traceOutputOptions=“Timestamp“>
- <filter type=“” />
- </add>
- </sharedListeners>
- <trace autoflush=“true“ />
- </system.diagnostics>
2. Run your application as usual until it throws the error or until the stage where you can reproduce your issue, once you are done, quit your application or take out the diagnostics section from the config file straight away so your log will not be growing too quickly/massively
3. The log file will be called as MyWCFTraceLog.svclog (as we define in the config file) and it will be located on the same folder as the executable – normally it is in the bin folder
4. How to open svclog file? Go to your program files (x86) or program files/Microsoft SDKs/Windows/v7.0A/Bin/SvcTraceViewer.exe
5. SVCTraceViewer will display you the story line of your WCF and it will help you to pinpoint the underlying issue