How to set up Elmah with ASP.NET Web API

前端 未结 4 2114
忘了有多久
忘了有多久 2021-01-31 08:18

I\'ve tried many elmah nugets but they didn\'t work with ASP.NET Web API. Does anybody knows why? Is there any work around for that?

4条回答
  •  爱一瞬间的悲伤
    2021-01-31 08:52

    For ASP.NET Web API use the Elmah.MVC nuget package, details of which are given below

    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 enter image description here

    Step 2: In the Nuget Package manager search for "Elmah" and install the Elmah.MVC nuget extension. enter image description here The Nuget Package manager will download and add the required dlls and modify the web.config's for Elmah to woenter image description hererk.

    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. enter image description here enter image description here

    Hope this helps :)

    Further Reading :

    • Elmah on code.google.com
    • Elmah.MVC 2.0.2 on Nuget
    • Elmah.MVC on GitHub

提交回复
热议问题