Reputation: 7203
I would like to achieve something to this extent:
I want to audit all of my controllers participating in serving http requests to the view files.
I would like to audit each and every method on that controller and write this information to the flat file (rolling logger??).
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
Upvotes: 0
Views: 363
Reputation: 93444
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
Upvotes: 3
Reputation: 34349
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.
Upvotes: 1