开发者

Elmah and ASP.NET MVC 3

What are the steps required to set up elmah on an ASP.开发者_开发技巧NET MVC 3 application?

  1. nuget elmah
  2. customize elmah (storage, etc)
  3. 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

Elmah and ASP.NET MVC 3

Step 2: In the Nuget Package manager search for "Elmah" and install the Elmah.MVC nuget extension.

Elmah and ASP.NET MVC 3

The Nuget Package manager will download and add the required dlls and modify the web.config's <appSetting> for Elmah to wo

Elmah and ASP.NET MVC 3

rk.

Step 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.

Elmah and ASP.NET MVC 3

Elmah and ASP.NET MVC 3

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.

  1. Nuget Elmah.mvc
  2. URL is http://microsoft.com/admin/elmah
  3. https://github.com/alexanderbeletsky/elmah.mvc/blob/master/README.md
  4. http://www.beletsky.net/2011/03/integrating-elmah-to-aspnet-mvc-in.html
  5. 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜