2

I'm trying to add logging in to application. Based on this blog post Logging with Ninject

It blog solves almost all my problems and even more. However there is one small issue that I cannot solve.

How to configure Ninject to always intercept virtual methods (with default interceptor) without configuring it on class or method level?

2
  • You should program to interfaces; not to base classes. This will solve your problems.
    – Steven
    Commented Aug 8, 2016 at 7:39
  • Hi @steven thanks for your answer I'm quite sure I don't understand what do you mean. Maybe I've not explained what I'd like to achieve. I want all virtual methods to always leave trace in logs "Method x run with params x' y'" but I don't want to do Bind<IInterceptedTestClass>() .To<InterceptedTestClass>() .Intercept().With<LogInterceptor>(); nor add any atributes to calses or methods.
    – Icen
    Commented Aug 8, 2016 at 8:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.