Download - ELMAH
Presenter: Harsh Wardhan, Mindfire Solutions
Agenda
- Importance of error logging.- Introducing ELMAH.- Installing and configuring ELMAH.- Best practices.
Presenter: Harsh Wardhan, Mindfire Solutions
Importance of error logging
Helps in tracking bug. Helps to evaluate application health. Organised logs save development time.
Presenter: Harsh Wardhan, Mindfire Solutions
Introducing ELMAH
Stands for Error Logging Modules And Handlers.
An open source project created by Atif Aziz.
Completely pluggable. Logs nearly all unhandled exceptions. Provides a web page to display all the
logged errors.
Presenter: Harsh Wardhan, Mindfire Solutions
Introducing ELMAH
Provides e-mail, twitter notification for all the errors as they occur.
RSS feed of last 15 errors logged. Provides different log storing options
including in-memory, SQL Server, SQLite.
Presenter: Harsh Wardhan, Mindfire Solutions
Installing ELMAH
Adding ELMAH assembly.Just drop the dll on your application's bin folder.ORInstall ELMAH NuGet package.
Presenter: Harsh Wardhan, Mindfire Solutions
Configuring ELMAH
Adding a section group which has information on how to log exceptions.
Adding a http module to log exception. Adding a http handler to view exception. Elmah section to set the logger type and
other settings.
Presenter: Harsh Wardhan, Mindfire Solutions
Configuring ELMAH
Adding a section group which has information on how to log exceptions.
<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>
Presenter: Harsh Wardhan, Mindfire Solutions
Configuring ELMAH
Adding a http module to log exception.
<system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules> <add name="Elmah.ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /> </modules> <handlers> <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" /> </handlers> </system.webServer>
Presenter: Harsh Wardhan, Mindfire Solutions
Configuring ELMAH
Adding a http handler to view exception. <system.web> <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>
Presenter: Harsh Wardhan, Mindfire Solutions
Configuring ELMAH
Elmah section to set the logger type and other settings.
<elmah> <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ELMAHConnectionString" /> </elmah>
Presenter: Harsh Wardhan, Mindfire Solutions
Logging handled exceptions
Raise an exception using ErrorSignal class of elmah.
ErrorSignal.FromCurrentContext().Raise(new Exception("I did it..."));
Presenter: Harsh Wardhan, Mindfire Solutions
Best Practices
Secure your logs by restricting remote access.
<elmah> <security allowRemoteAccess="False" /></elmah>
Set roles to access the log.