Thursday 4 July 2013

Semantic Logging in WCF service

Implementing Semantic Logging Application Block in a WCF service is as straightforward as implementing it a normal .NET application - because it is all .NET :).
 
So I tried to create one simple implementation of semantic logging in a simple WCF service for demo purpose. The idea was not to implement or develop any SLAB pattern for WCF but instead show that SLAB implementation can be started in as straightforward manner as you would do it for an ASP.NET website or a Windows Forms application etc. Technically, there is no limitation in exposing your SLAB implementation for capturing business events as a service (WCF, REST or OData, anything else) as well which means you should be able to capture business events and data in a structured format and process the stored information to make educated decisions (perhaps a good analysis engine or a good visualization engine).
 
I have used the default service that gets created when you chose to create a new WCF Service application (IService1 is the contract and Service1 is the implementation, hosted with default WCF configuration provided in Web.Config). Only change in the service is the usage of SLAB component.



Implementation of BusinessClassEventListener has been defaulted to log data in a file but you can always be more creative about it for your own benefit. Here are the rest of the classes (of course, you need to add SLAB reference to the project - recommended way is to use NuGet package of SLAB).
 
 
 
 
This is just a sample implementation for reference and definitely not production ready or even "complete" for that matter. I take no responsibility if this fails in your application :). Hope this gives you a good starting point.