0

I'm in the process of writing an application framework that will be consumed by a number of client applications and used as the core that they're built on top of. The framework itself is an MVC3 (currently) application that is consumed as a Nuget package and provides, amongst other things, a locked down layout, UI templates and a unified approach for things like IoC, packaging for deployment, etc. One issue we are wrestling with at the moment is introducing logging of method entry and exit across the client applications. This is not a new subject on SO - I've looked at a couple of posts dealing with it:

Ideally, I'd like developers of the client applications to not have to think about this level of logging and have the framework take care of it in the background without the developers needing to make any changes to their code. As mentioned in the linked posts, there are things like PostSharp and other AOP frameworks, but they still rely on attributes being added to enable the logging, which makes the client developers responsible for adding those attributes. Ideally I want the framework code to manage all of that without the client developers having to do anything. It feels like the kind of thing that one of the IoC frameworks should offer but I haven't found anything that fits the bill as yet. We're currently using NInject for the framework IoC container but that may change so I'm not bound to any specific container. Neither am I bound to a specific logging framework. Thoughts?

4

2 に答える 2

1

Autofacには、DynamicProxyを使用してメソッドインターセプトを実現する拡張機能があります。これを使用して、IoCコンテナーを介して(またはアプリケーションフレームワークで定義した規則に従って)解決されるアプリケーション内のすべてのクラスでメソッドの開始と終了のログを設定できます。http://code.google.com/p/autofac/wiki/DynamicProxy2

于 2013-02-12T09:44:15.773 に答える
0

Unity provides a very good framework for method interception. On the MSDN, there is an article describing how to use this framework on crosscutting concerns. An example of code is provided for Logging and Caching. https://msdn.microsoft.com/en-us/library/dn178466(v=pandp.30).aspx

于 2015-05-18T09:16:32.893 に答える