What are the steps required to set up elmah on an ASP.开发者_开发技巧NET MVC 3 application?
- nuget elmah
- customize elmah (storage, etc)
- handle HandleError
Is that all? Is step 3 still necessary after nuget?
Taken from : HOW TO SETUP ELMAH.MVC WITH ASP.NET MVC 4 ?
What is Elmah ?
ELMAH is an open source project whose purpose is to log and report unhandled exceptions in ASP.NET web applications.
Why to use Elmah ?
ELMAH serves as an unobtrusive interceptor of unhandled ASP.NET exceptions, those usually manifesting with the ASP.NET yellow screen of death.
So now we know what and why to use Elmah, Lets quickly get started on how to use Elmah with your ASP.NET MVC project.
Step 1: Right click on your solution and select the "Manage Nuget Packages" option
Step 2: In the Nuget Package manager search for "Elmah" and install the Elmah.MVC nuget extension.
<appSetting>
for Elmah to woStep 3: That's it !! Your Elmah is now ready to test. I have generated a 404 to test if my Elmah works, ELMAH can be accessed by this url : http://yourapp.com/elmah.
Hope this helps :)
Further Reading :
- Elmah on code.google.com
- Elmah.MVC 2.0.2 on Nuget
- Elmah.MVC on GitHub
I used ELMAH in 2010 and 2011. Now it is 2012, and I just added it to a new MVC 3 project and noticed the latest release made it much easier.
- Nuget Elmah.mvc
- URL is http://microsoft.com/admin/elmah
- https://github.com/alexanderbeletsky/elmah.mvc/blob/master/README.md
- http://www.beletsky.net/2011/03/integrating-elmah-to-aspnet-mvc-in.html
- https://github.com/alexanderbeletsky/elmah.mvc
Is that all? Is step 3 still necessary after nuget?
You should really set up a database table in MSSQL or another reliable DB to feed your errors into so they can be retrieved and stored reliably.
Otherwise no, there is no real config needed but you would likely use Email as well as block specific annoying errors.
After a quick google I found this: http://kurtschindler.net/blog/post/Configuring-ELMAH-on-DiscountASPNET
It turned out step 1 and 2 can be combined by nuget-ing "elmah on xml log", which will set up web.config so elmah will log errors into separate xml files. So no need to edit the config by hand at all, except to further customize elmah.
Step 3 is still necessary.
Elmah is already available for MVC http://nuget.org/List/Packages/Elmah.MVC/1.2
basically, the hard bit is getting the Elmah config (in web.config) correct as the documentation is a little rough in my eyes
精彩评论