pithhelmet
pithhelmet

Reputation: 2292

overload the ActionResult in MVC3

Please provide direction if this is a good idea or not....

I have a customer that wants VERY detailed application logging in the system. They want to track every click and the page and control that was clicked.

I was thinking that a nice stored procedure on the SQL server would allow me to keep that information, but getting that level of information into the database is the question.

I was thinking about adding a single entry in the EF to post the information into the SQL server within every ActionResult block of code, but it occured to me, that maybe i can just override the ActionResult and do it that way....

anyone ever do anything like that?

tia

Upvotes: 0

Views: 263

Answers (2)

Akos Lukacs
Akos Lukacs

Reputation: 2047

You can log all kinds of thing using ActionFilters. This article even has a logging example. By the way, the same action filters also can help you during debugging, so you see what happened before the exception.

And if your customer want super crazy trace info, you can log MiniProfiler's logging and tracing information, that contains all kinds of extra info like actual db calls and things like that.

But as Andre already mentioned, use a different db, and save the results asynchronously.

Edit:

This method logs what actually happened in the application, the actual results of user actions, if your customer needs logging for auditing, or something like that, ActionFilters are for you.

If your customer wants to track usage statistics, something like a web page heat map, well, look at the search results :-)

Upvotes: 1

Andre Calil
Andre Calil

Reputation: 7692

this is not an aswer, but there is one point that you must consider and I'd like to discuss it.

If you need tracking log with so much detail (like where the user clicked at the page), them I'd strongly suggest you to don't store these logs on the same database that the app uses, because scalability will be a problem. Moreover, tracking logs are a good match for a NoSQL database. As most of these databases work with a REST API, turns out that this is a perfect solution to track user interaction using javascript.

Think about it. You'll have an isolated REST webservice to store your tracking logs. They can be sent from C# (from a Controller or wherever) and from the view, easily.

Any feedback will be appreciated. As I said, this is not an answer, but think of it as a brainstorming.

Regards

Upvotes: 0

Related Questions