GoodStuff.Diagnostics.ExceptionHandlerModule

Similar to ELMAH, but older, this module is used to log asp.net toplevel exceptions. This handler has two major features:
  • Logging the exception details to a database
  • Sending an email message to configured recipients for each exception

Both features are customizable and can be used independent of each other.

Sample Configuration

 <sectionGroup name="goodStuff">
      <section name="exceptionHandlerConfiguration"       type="GoodStuff.Diagnostics.ExceptionHandlerConfigurationSectionHandler, GoodStuff"/>
 </sectionGroup>

 <goodStuff>
    <exceptionHandlerConfiguration enabled="true">
      <mailer from="noreply@site.com" recipients="dummy@output.com">
        <!-- IP Based -->
        <!--
        <exclude sourceIP="192.168.1.203"/>
        <exclude sourceIP="10.1.1.0/24"/>
        -->
        <!-- Based on main Exception -->
        <exclude typeName="System.Web.UI.ViewStateException"/>
        <exclude message="Invalid viewstate." compareMethod="Exact"/>
        <exclude message="Ongeldige weergave" compareMethod="Contains"/>
        <exclude message="reference not set to an instance" compareMethod="StartsWith"/>
      </mailer>
      <sql connectionName="Database">
        <exclude message="reference not set to an instance" compareMethod="StartsWith"/>
      </sql>
    </exceptionHandlerConfiguration>
    ....
 </goodStuff>

<connectionStrings>
    <add name="GoodStuffDemo" connectionString="Data Source=(LOCAL);Initial Catalog=GoodStuff;Integrated Security=True"/>   
  </connectionStrings>


After the configuration, you must add the module to the httpModules.

IMPORTANT: If you run in II7 integrated mode, you must add the module to the <system.Webserver><modules> section!

   <httpModules>
      <add name="ExceptionLogger" type="GoodStuff.Diagnostics.ExceptionModule, GoodStuff"/>
    </httpModules>


If you are using the Sql module to log exceptions to the database, here's the SQL script to create the table: LogEntry.sql

Quick Sql Exception Viewer

To be able to view the SQL exception log, you will have to register the viewer handler

   <httpHandlers>
      <add verb="GET" path="Exceptions.axd" type="GoodStuff.Diagnostics.ExceptionHandlerSqlViewer, GoodStuff"/>
    </httpHandlers>


Access the log by browsing to the /exceptions.axd page of your web site. It is strongly advised to secure access to the page using a <location> section.

Last edited Oct 12, 2011 at 4:01 PM by drblame, version 7

Comments

No comments yet.