Elmah

From Logic Wiki
Jump to: navigation, search


Elmah is a error logging tool. To install it into project, first we have to add it via Nuget

PM> Install-Package Elmah.MVC.XMLLight 

It adds necessary lines to web.config and errors can be seen by domain:xxxx/elmah.axd

To store logs in database get relevant script for each database from https://code.google.com/p/elmah/wiki/Downloads?tm=2#ELMAH_1.2_SP2

In Web.config file database should be pointed like this

<?xml version="1.0"?>
<configuration>
  <configSections>
    <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" />
    </sectionGroup>
  </configSections>
  <connectionStrings>
    <add name="elmah-express" connectionString="Server=KAZOL-PC\SQLEXPRESS08; Database=Elmah_Errorlog;Trusted_Connection=Yes;" />
  </connectionStrings>
  <elmah>
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="elmah-express" />
    <errorFilter>
      <test>
        <equal binding="HttpStatusCode" value="404" valueType="Int32" />
      </test>
    </errorFilter>
  </elmah>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpHandlers>
      <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
    </httpHandlers>
    <httpModules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
    </httpModules>
  </system.web>
</configuration>