问题
Background
I had [HandleError] in place in my MVC web app for exception handling but later it couldn't handle some exceptions so I was suggested to move on to the alternative Application_Error (my SO Post) I also ended up using ELMAH which seems better.
Well, ELMAH rocks! But I was unable to find how to show formatted exception with it (like I do with Application_Error)
ELMAH v/s Application_Error
ELMAH - Provides (almost) out of the box exception logging and other features like email. Its completely dependent on web.config and a bunch of files it requires. Able to log exception in xml / database (as configured) and is capable of email, rss, etc. Provides a page where user can view the full exception log and drilldown for details.
Pros: Doesn't show formatted exception upon error. Makes the web.config a bit bulky. The set of ELMAH files is 2.8mb (more then twice the size of my entire web app zip). Can't format error / email. It is dependent on System.Data.SQLite.dll which is CPU architectue dependent (x64 or x86) SO post
Application_Error - Catches all the exception and we're able to navigate user to show a formatted error. We control what is being showed and Emailed. Completely managed code (no CPU dependency) no extra web.config settings. No extra dlls.
Pros: No implicit exception logging (we need to code). No log viewer like ELMAH. Email, logging - we've to manage all.
CONCLUSION: Firstly, please tell me if ELMAH can "completely" replace my Application_Error. Also, I didn't find much on how to configure the error message being displayed / emailed with ELMAH. Or do they have to co-exist (Application_Error to show formatted error and ELMAH for pretty much everything else)
Please suggest and share your experience.
回答1:
I can live with ELMAH (except for showing formatted exception details to the user - or atleast I didn't find anything for that)
I wonder what was missing in my post to attract SO audience. I got my thread answered by Atif himself - quicker, simpler!
https://groups.google.com/forum/?fromgroups=#!topic/elmah/Md9DslGgwNo
来源:https://stackoverflow.com/questions/12412214/mvc-elmah-v-s-application-error