Filter posts by Category Or Tag of the Blog section!

using Elmah in MVC

Tuesday, 20 November 2012

Elmah is one the most popular libraries for handling the unhandled errors which is provided by Google (I'm not sure about google support). Using Elmah is super easy you can do that without even writing a line of code! Just get the latest version from Nuget package manager. After installing navigate to yourlocalHost/elmah.axd , you will see the page below:


Finished! From now on you can see every exception and the yellow page errors in that page. If you go the web.config, there would be some configuration for Elmah, for example in sectionGroup:


 <sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />


And a httpModules:


      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
    <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /><add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /><add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /></httpModules>

And a elmah section:

        See for 
        more information on remote access and securing ELMAH.
    <security allowRemoteAccess="false" />
  </elmah><location path="elmah.axd" inheritInChildApplications="false">
        <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
        See for 
        more information on using ASP.NET authorization securing ELMAH.

        <allow roles="admin" />
        <deny users="*" />  
        <add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />


You can still set your custom error as true and redirect the users to your custom error page while having the Elmah logging. By the way, now I'm sure that Elmah is supported by google!

comments powered by Disqus