Reputation: 77329
I'd like to implement some kind of automatic "logging" in my ASP.NET MVC application when a page execution (incl. database calls etc.) takes longer than 3 seconds, and then gather some 'circumstantial evidence', e.g. which action was called, what the parameters were, session information etc. so I can then store that info for review/send it via email and so forth.
How could I do this, preferably on a global level without editing/adding code to each of my many controller actions?
Upvotes: 2
Views: 703
Reputation: 32391
Start by looking at the global.asax methods that hook into the following events:
-- Application_BeginRequest
-- Application_EndRequest
Record the time in the fist, compare it to current time in the last - if it's too long log it. You can probably get the action etc from the HttpContext.Current.
Upvotes: 2