ELMAH HttpModule

Concept

The ELMAH HttpModule is created to make sure that all the errors are caught on a website or web application. If an error where to occur on or in the ELMAH HttpModule the error won’t be logged to the folder as an xml file, but will be written to the trace instead. The philosophy behind this is that an application should not stop working just because the error logging system does not work.

Installation / Configuration

Dowload OrbitOne.Elmah.HttpModule.Zip and extract somewhere.
The zip file contains 2 folders: the .Net 2.0 and the .Net 1.1

If you have both versions of websites you can use all 4 dll’s at the same time. If you only need one of the two versions, there is no need to copy the other version.
I’ll assume you know which version you need.

For the .Net 2.0 version the public key token = ab9cc0e617757f7b
For the .Net 1.1 version the public key token = d633d0581a25beaf

Add the redirection of the errors to the web.config of your websites/webapps:
<customErrors>
	<error statusCode="500" redirect="500.html" />
	<error statusCode="404" redirect="404.html" />
</customErrors>

Next chose how you want to log and follow the steps below

Configuration at Machine Level

This is only needed when you want to monitor all the sites on your server. No additional configurations will be needed.

To install the modules at machine level you have to complete following steps:
  • Place the dlls for the version you need in the GAC (%windir%\assembly)
    • Elmah.dll (version 1.0.8925.10000)
    • OrbitOne.Elmah.dll (version 1.0.0.0, Culture=neutral)
You can either drag and drop the assemblies to %windir%\assembly, or install them using gacutil:
gacutil.exe /i OrbitOne.Elmah.dll
gacutil.exe /i Elmah.dll
  • Open the machine.config file on your system (%windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config)
  • And add the following to the configSections section:
<sectionGroup name="OrbitOne.Elmah">
       <section name="errorLog" 
	requirePermission="false" 
	type="OrbitOne.Elmah.HttpModule.LogSectionHandler, OrbitOne.Elmah, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ab9cc0e617757f7b" />
      <section name="errorFilter" 
	requirePermission="false" 
	type="OrbitOne.Elmah.HttpModule.FilterSectionHandler, OrbitOne.Elmah, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ab9cc0e617757f7b" />
</sectionGroup>
  • And add the OrbitOne.Elmah section:
<OrbitOne.Elmah>
	<errorLog type="OrbitOne.Elmah.O1XmlFileErrorLog, OrbitOne.Elmah, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ab9cc0e617757f7b" 
		LogPath="C:\Program Files (x86)\Orbit One\Orbit One Elmah Agent Service\Logs" />
	<errorFilter>
		<filters>
			<equal binding="HttpStatusCode" value="404" ValueType="Int32" />
		</filters>
	</errorFilter>
</OrbitOne.Elmah>
  • Next add to the System.Web.HttpModules section. Make sure the first element in the section is the errorLog:

<httpModules>
      <add name="ErrorLog" 
	type="OrbitOne.Elmah.HttpModule.O1ErrorLogModule, OrbitOne.Elmah, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ab9cc0e617757f7b" />
      <add name="ErrorFilter" 
	type="OrbitOne.Elmah.HttpModule.O1ErrorFilterModule, OrbitOne.Elmah, Version=1.0.0.0,Culture=neutral, PublicKeyToken=ab9cc0e617757f7b" />
</httpModules>

Configuration at Site Level

To install the module on a single site, place the Elmah.dll and the OrbitOne.Elmah.dll in your website/webapp’s bin directory. Next follow the steps of the machine level and apply those in your web.config.

Configuration for SharePoint Site

  • For SharePoint 2003 site: use the .Net 1.1 version.
  • For SharePoint 2007 site: use the .Net 2.0 version.
There is only one difference with a regular site level installation. You need to change the redirection of the custom error pages as following:
<customErrors>
	<error statusCode="500" redirect="~/_layouts/1033/error.aspx" />
</customErrors>

Last edited Jan 28, 2011 at 8:42 AM by melg, version 11

Comments

No comments yet.