Issue in logging using interception

Topics: Policy Injection Application Block
May 5, 2011 at 3:22 PM

Hello All,

I'm evaluating Enterprise Library "Interception" block to implement the logging in my application. I have gone through till Lab 4 but I'm not able to figure out how to implement it properly. I'm trying to implement for a scenario where at least three objects are involved horizontally. Caller-->A--->B---->C. I'm thinking of having "IInterceptionBehavior" before each object instance to log the all methods names (from A to C) along with their parameter value. I'm using InterfaceInterceptor, all of objects implement an interface. I have tried hard but I'm not able to figure out the correct approach to log exceptions. If an exception occurred in a method in "C" object, I'm not sure in which "IInterceptionBehavior" instance I should log it. 

-If I log the exception in in "IInterceptionBehavior" instance before "C" object then how can I stop "IInterceptionBehavior" instances inserted before A and B objects from logging that exception again?  I don't want to suppress the exception by setting IMethodReturn.Exception to null.

-And if I log the exception in "IInterceptionBehavior" instance before "A" object, I don't get the correct stack trace because interception proxy is re-throwing exception and exception has the stack trace of proxy not of object "C".

Thank you for your help.

Gurmit

May 5, 2011 at 8:46 PM

Are you already using custom call handlers here? If not yet, I believe this is a one way you can do this. The implementation of Call Handler has a way to abort execution within the pipeline. Please see the documentation reference for this (http://msdn.microsoft.com/en-us/library/ff660871(v=PandP.20).aspx) and check out if this can help solved your problem.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jun 8, 2011 at 6:26 PM
Edited Jun 8, 2011 at 6:26 PM

Sorry I could respond as I was on vacation. No, that does not solve my problem. Could you please give some idea how above mentioned link can solve my problem?

 

Gurmit

Jun 9, 2011 at 9:06 AM

I realize I got a little lost from my initial post after thinking thru that what are you trying to use is InterfaceBehavior approach :o).  Anyway, I'm not sure regarding the specific scenario you would want to achieve but I'm thinking creating custom InterfaceBehavior would help you to customize the behavior you would want to and will let you have control when you should do your logging. HTH

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com