Configure ELMAH on your site

  1. Install the ELMAH on SQL Server package from the NuGet repository.

    NOTE: ELMAH on SQL Server package is version 1.2. It has a dependency to the ELMAH package, which must be version 1.2.2. You can also install the ELMAH NuGet package, version 1.2.2, from the NuGet repository.

  2. Make sure the elmah section group is added inside the <configSections> tag in the web.config file. If not, add the section group manually:

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

    NOTE: Мake sure the Elmah.dll file is loaded in the bin folder of your Sitefinity CMS web application.

  3. Complete the installation of the ELMAH.SqlServer:

    1. Create a new database to host ELMAH.

    2. Run the Elmah.SqlServer.sql script against an empty ELMAH database.

      NOTE: You can find the script in the ELMAH GitHub repository Downloads section. Download the Sources ZIP file.

  4. Open the web.config file of your application and perform the following transformations:

    XML
    <!-- Find the following connection string and replace the asteriks with the correct entries -->
    
    <connectionStrings>
        <add name="elmah-sqlserver" connectionString="Data Source=****;User ID=****;Password=****;Initial Catalog=****;" providerName="System.Data.SqlClient" />
    </connectionStrings>
    
    <!-- In the <httpModules> section, add the following line: -->
    
    <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
              
    <!-- In the <modules> section, add the following line: -->
    
    <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
  5. (Optional) To send email notifications for each error at the time it occurs, you must configure your SMTP settings.

    If you do not have an SMTP server, you can download the open source smtp4dev and configure it to listen on port 26.
    To do this, in your web.config file, after the <configSections> tag, add the following:

    XML
    <system.net>
        <mailSettings>
            <smtp deliveryMethod ="Network">
                <network host="localhost" port="26" />
            </smtp>
        </mailSettings>
    </system.net>
    
    <elmah> 
        <errorMail from="testemail@domain.com" to="youremail@domain.com" async="true" useSsl="false" /> 
    </elmah>
  6. (Optional) Register ELMAH handler by adding the following code line in the <handlers> and the <httpHandlers> sections in the web.config file:

    XML
    <add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />

    For more information about the ELMAH error logging handler, see Test error logging with ELMAH.

  7. To turn on ELMAH, navigate to Administration » Settings » Advanced » System » UI Elmah Config.

  8. Select the IsElmahLoggingTurnedOn checkbox and click Save changes.
    Every time you change the selection of this checkbox, you must restart the application.

    NOTE: When the ELMAH logging is turned off, the standard logging is working and you can see all the logging information in App_Data/Sitefinity/Logs. When you select the IsElmahLoggingTurnedOn checkbox, all logging information is transferred to ELMAH.

Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
New to Sitefinity?