Using log4net we would like to log all calls to our ASP.NET MVC controller action methods.
The logs should include information about any parameters that were passed to the controller.
Rather than hand-coding this in each action method we hope to use an AoP approach with Interceptors via Unity.
We already have this working with some other classes that use interfaces (using the InterfaceInterceptor
). However, we're not sure how to proceed with our controllers. Should we re-work them slightly to use an interface, or is there a simpler approach?
Edit
The VirtualMethodInterceptor seems to be the correct approach, however using this results in the following exception:
System.ArgumentNullException: Value cannot be null. Parameter name: str at System.Reflection.Emit.DynamicILGenerator.Emit(OpCode opcode, String str) at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.PreBuildUp(IBuilderContext context) at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)