tags:

views:

166

answers:

2

I have a WCF service (happy joy) all my messages inherit from the abstract class MessageBase and implements the below interface.

public interface IMessageBase<T> where T : class
{
    String Serialize(T data);
    T Deserialize(string text);
}

Each time one of my operation contracts is hit with a message like this I want to log this message. As soon as a method is requested and one of the inbound parameters is assignable to IMessageBase then I want to execute logging without fudging with the actual method. How would I achieve this? I suppose I would need to do this in my IDispatchMessageInspector but how?

+2  A: 

Check out a few good resources:

marc_s
I just added a LoggingMessageInspector. First there was a lone UnitOfWorkMessageInspector in the wolfpack. Then came along a LoggingMessageInspector and joined the wolfpack. And they were the 2 best friends that anyone can have!
mhenrixon
+1  A: 

If this is for out-of-process auditing or debugging you could just add a trace or message log in .config. Try the wcf configuration editor, it is simple to do and writes out xml files that you can either view using the provided tools or parse as needed.

If you are looking for realtime results to be handled as the request is being made see the other answers regarding message inspector.

Sky Sanders