Reputation: 1998
I am going to handle a project to a client for a testing phase, the project build with ASP.NET MVC3 .. What I need is to save all exceptions occurs to a persistent location -SQL Database-
and I have some questions..
Upvotes: 1
Views: 2220
Reputation: 6862
Upvotes: 1
Reputation: 1500425
what field should I save in the database? (Msg, trace, etc)
Everything you can, if possible:
I have seen people save the inner exception but sometimes my exceptions have null inner exception.
And some will have more than one, nested. You should save everything you can, IMO. How you structure that is up to you, but you could always add the innermost one, then the containining one with a foreign key to the innermost one, etc, working your way outwards.
What is the best place to handle the error and save to the DB.
Can't help you on that part, I'm afraid. You may want to consider doing this asynchronously though, queuing them up. This is particularly relevant when the exception may itself be a database error - if you can build up a queue (with a maximum size, of course) so that once any database problems have been restored, the errors can then be stored, that could be useful. Or potentially dump them to disk first, and periodically upload that log to the database.
Upvotes: 4