Posted by eric in C# Programming, General Programming, Microsoft .NET 3.0 / WinFX on May 19, 2007
Microsoft already provides a couple great listeners that are great for debugging. The two most commonly used are XmlWriterTraceListener and TextWriterTraceListener, which both dump the diagnostic messages to the file you specify in the configuration options. Microsoft has a great article on how to use these trace listeners for message logging within a WCF application here.
The issue that I ran into was I wanted to log these messages not to the file system, but to the database. Microsoft provides for this in allowing people to create custom Trace Listeners. After some heavy Googling I was able to find this article on MSDN which describes a method in which you would be able to create a custom Trace Listener. Using the code from this article, I was able to boil it down to a simple code shell which anyone could take and use within their WCF application.
This is very helpful for people looking to capture and log the incoming and outgoing SOAP messages to their WCF application without having to create a custom dispatcher. On top of that, creating a Listener provides a drag-and-drop assembly you can use on any future project you might create.
The code for this project can be found here (ZIP, 5.4k). The solution was created using Visual Studio 2005.
Cheers!
Fusion theme by digitalnature | powered by WordPress
Entries (RSS) and Comments (RSS) ^