lessphp fatal error: load error: failed to find E:\HostingSpaces\ntellex\xavierstallings.com\wwwroot/wp-content/themes/theme50663/bootstrap/less/bootstrap.lesslessphp fatal error: load error: failed to find E:\HostingSpaces\ntellex\xavierstallings.com\wwwroot/wp-content/themes/theme50663/style.less Sitecore Logging Extensions Part 1: ELMAH

Sitecore Logging Extensions Part 1: ELMAH

logging-elmah-viewer

Introduction

Elmah is a great error logging extension that can be added to Sitecore with relative ease.  In this series we will first look at why something like Elmah is a great extension for Sitecore and how easily it can be added to a platform.

In the next Part of this extension we will look at adding services for Realtime error log monitoring with Papertrail.  And we will wrap up the series by looking at adding the new Azure Application Insights for cloud monitoring.

Why Extend Sitecore Logging

Sitecore OOTB (out-of-the-box), comes with a great and error logging solution using Log4net.  However, in real life when a developer needs access to logs these are only accessible through the Siecore Admin or with access to the Web Server hosting the Sitecore solution.  Today many solutions are not exclusively done by "in-house" teams, so being able to access logs and view logs remotely is a must! Before something breaks and it's A MUST!

Developer Level: Beginner

This will actually require no code!

  • Database Configuration.  Go to the Elmah Git Repo and download the database scripts specific to your solution.  For this article we will assume you are using SQL Server.  Create a database and execute the downloaded SQL script against your newly created database.
  • Application Configuration.  There are several critical areas in the web.config that will need configuration.  Luckily using NuGET will actually update the web.config in your project and we can simply modify the necessary location.
    Assuming NuGET was successful let's focus on the configurations that need modification

    • ConnectionString.config - Add your connectionstring to the Database that was created.  The name of the element will be referenced later in other configs
      <add name="elmah" connectionString="Data Source=xxx;Initial Catalog=marketingvillage_elmah;Integrated Security=False;User ID=sa;Password=b" />
    •  Web.config - We now need to make some path updates to the handler locations added by NuGET.
      <handlers>
              <add name="ELMAH" verb="POST,GET,HEAD" path="sitecore/admin/elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
            </handlers>

      I like to hide my elmah path behind Sitecore's admin, that way I can utilize Role access.

    • Sitecore.config - Since I have placed the handler path at "sitecore/admin/elmah.axd", we need to make changes to the Sitecore Setting IgnoreUrlPrefixes.  This will ensure that Sitecore allows the elmah.axd to load up once we have authenticated.
      <setting name="IgnoreUrlPrefixes" value="/sitecore/default.aspx|/sitecore/admin/elmah.axd|/trace.axd|.../>
Just that simple.  You should be able to browse to the following url and reach the ELMAH logs: http://[your-domain]/sitecore/admin/elmah.axd
In the next series we will extend log4net to connect to a realtime logging service, and then we'll connect it to Azure Application Insights logging.

No Comments Yet.

Leave a comment