Asp.net mvc 3 mvc3的日志记录策略

Asp.net mvc 3 mvc3的日志记录策略,asp.net-mvc-3,dependency-injection,unity-container,enterprise-library,Asp.net Mvc 3,Dependency Injection,Unity Container,Enterprise Library,你好,我正在写一些东西,将在多个即将发布的版本中进行扩展。我现在提到这一点的唯一原因是,必须跟踪和记录控制器中包含的新功能: 例子 0.0版-一个获取一些信息的方法..只需记录它被击中的事实并捕获Http请求的标识(保证在那时通过身份验证): 股票控制员: ///I dont want to use the var LogWriter logger ///EnterpriseLibraryContainer.Current.GetInstance<LogWriter>(

你好,我正在写一些东西,将在多个即将发布的版本中进行扩展。我现在提到这一点的唯一原因是,必须跟踪和记录控制器中包含的新功能:

例子

  • 0.0版-一个获取一些信息的方法..只需记录它被击中的事实并捕获Http请求的标识(保证在那时通过身份验证):
  • 股票控制员:

       ///I dont want to use the var LogWriter logger 
       ///EnterpriseLibraryContainer.Current.GetInstance<LogWriter>()
       ///Instead I would like to use injection and just deco the method with something like this
       [CaptureMethodVisit4Loggin(Category.Info, captureIdentity=true, trace = true)]
       ViewResult Index() 
       {
            var stuff = ServiceLocator.GetMyComponent<ForStuff>();
            return View(stuff.GetAll());
    
       }
    
       ///Same here - I dont want to write logging code with every new release instead
       ///all methods on the controller should by default have the 
       [CaptureReadWriteMethodVisitForLogging(Category.Info, trackID = true, trace = true)]
       ActionResult RegisterStock(int registrarID, Ticker ticker) 
       {
    
             //do some crazy stuff.
    
       }
    
    就这样。。。引入了新方法—有些方法可能没有该属性—在这种情况下,它们将获得一些默认的日志输出

    这可以通过Entlib5.0实现吗