0

I would like to achieve something to this extent:

  1. I want to audit all of my controllers participating in serving http requests to the view files.

  2. I would like to audit each and every method on that controller and write this information to the flat file (rolling logger??).

  3. The audit log should contain: authenticated user info, method called, method parameters, time stamp.

I realize that this would require implementing my own controller factory to do something like this:

    //policy injection call that is set up to log all the methods, called on the 
   //controller.
   var myController = ControllerCustomerFactory<FlatRollingLogger>.Create();

what should I do next, should I inject the custom created controller somewhere else or the factory will keep track on which controller needs to be instantiated?

I was thinking Microsoft Ent Lib Policy Injection as it has been done for other auditing purposes in our company?

Any other better ideas to handle this?

merci

tereško
  • 58,060
  • 25
  • 98
  • 150
dexter
  • 7,063
  • 9
  • 54
  • 71

2 Answers2

3

No, you don't need your own factory controller, just create a global action filter. MVC is very extensible.

http://weblogs.asp.net/gunnarpeipman/archive/2010/08/15/asp-net-mvc-3-global-action-filters.aspx

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
1

You might want to consider an aspect oriented approach using a framework such as PostSharp. You can use a logging framework such as log4net to perform the actual logging.

devdigital
  • 34,151
  • 9
  • 98
  • 120