Performing logging operations in MVC .NET

Fant0m4s

New Member
i'm trying to work out the best method to perform logging in the application i'm currently developing. right now, i have a Log table that stores the username, timestamp, action, controller, and a message. when a controller is instantiated, it gets the IoC info through Castle Windsor.for example, my "Sites" controller is created as follows:\[code\] private ISitesRepository siteRepository; private ILogWriter logWriter; public SiteController(ISitesRepository siteRepository, ILogWriter logWriter) { this.siteRepository = siteRepository; this.logWriter = logWriter; }\[/code\]and the log writer has a function that creates and inserts a log entry (WriteToLog). within the Sites controller's Edit and Create actions, it calls the WriteToLog function.this is working and doing its job, but my question is- do i really need to set up each controller this way, passing through the ILogWriter interface/repository? it struck me that i could possibly set up a LogController, and just have that do the "heavy lifting" of writing to my logs.that way, i wouldn't have to mess with the IoC stuff in every other controller. is it possible to execute an action on another controller (for example, a LogController-> WriteLog)? i'm not sure how would that be done without doing a redirect...
 
Back
Top