In this post I will shortly describe how to enable and use WCF-Message-Tracing.
1. Add tracing to your web.config of the WCF-Service. I use WCF-Config-Editor for this task, so I don’t have to keep all this xml nodes and settings in mind.
When you have started the WCF Service Configuration Editor once a time in a Visual Studio session, you can use the context menu of the web.config file to open it.
2. In the WCF Config Editor you can enable the logging for the service messages (Usually when I wan to debug a service I enable everything I can get)
Make sure that the logging and tracing files are written to path that exists on the hosting environment (usually I enter only the filename without path so the log-files are written in the service directory)
3. After deploying your new configuration it is time to call your service and let the WCF write some traces…
4. After your service call it might be necessary to reset the application pool of the WCF service to flush the WCF log writer (sometimes log is not written when the call has ended). Normally I do this using iisreset command (one of my dev-favorite commands ;-) but you can although recycle the app-pool
5. Go and take a look at your log files.If you have chosen the same brute-force logging as I did on my screenshots you should see two log files created with the extension ’svclog’.
6. Give it a try and feel the pain open this file using notepad…
7. Now open the ‘Service Trace Viewer’ tool which you can find in "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\SvcTraceViewer.exe" or "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\SvcTraceViewer.exe".Using Vista or 7 you just have to type ‘trace’ in the start search field and you will see the tool…
8. Just drag&drop both log-files in the tool. The Trace Viewer will do the linking between the trace- and log-file
9. Start analyzing your messages and find the annoying bug you are chasing for…
10. Important: Because tracing and logging has impact to the performance of the WCF-Service don’t forget to disable or at least reduce it (e.g. log only errors) when you are finished.
More information about logging and tracing in WCF you can find in the MSDN:
Posted
Nov 12 2009, 08:14 PM
by
alehmann