2008-10-26 109 views
7

在使用AOP,Castle和.NET应用程序登录时是否有任何教程或示例程序?我在那里找到了一些片断,但我正在寻找更多的东西来帮助我形成一幅更完整的画面。Castle,AOP和.NET中的日志记录

感谢, -Brian

+1

试试Ayende的博客: [http://ayen.com/.com/logive/2008/07/31/Logging--the-AOP-way.aspx](http://ayende.com/Blog /archive/2008/07/31/Logging--the-AOP-way.aspx) – nocache 2008-11-03 03:52:44

回答

8

您需要使用自定义拦截器,它从IInterceptor继承。例如:

public class LogInterceptor : IInterceptor 
{  
    public void Intercept(IInvocation invocation) 
    { 
     Logger.Write("I'm in your method logging your access"); 
     invocation.Proceed(); 
    } 
} 

希望这会有所帮助。