Table of Content

Introduction

Prerequisites

Installation

Cultural settings

Heartbeat service

Tips

Introduction

Welcome to the ELMAH Dashboard ReadMe doucment.

Once installed and configured, you can copy the following link to access the ELMAH Dashboard pages:

   <A HREF="/MvcElmahDashboard">ELMAH Dashboard</A>

Or for best compatibility, add the Web application root operator (~) in front of the URL when inside an ASP.NET forms, view or Razor view:

   <A HREF="~/MvcElmahDashboard">ELMAH Dashboard</A>

Prerequisites

Having the ELMAH Error Logging Modules and Handlers for ASP.NET installed on this website is not a requirement. The ELMAH Dashboard shows ELMAH logs form an SQL Server database. Whether those logs come from this website or from (an)other site(s) does not matter.

What does matter however, is:

  • This application hosting the ELMAH Dashboard must be an ASP.NET MVC web application.
  • The ELMAH logs to display are stored in a SQL Server database.

Installation

You just installed the Arebis.Web.Mvc.ElmahDashboard NuGet package ? You may still have the following steps to go:

1. Ensure the ELMAH Dashboard's MVC area is configured, i.e. by having a call to

    AreaRegistration.RegisterAllAreas();

in the Application_Start method of the Global.asax's codebehind file.

2. Configure the connection to the ELMAH database.

Ensure you have the database connection string configured in your web.config:

    <connectionstrings>
      <add name="whatever" connectionstring="..." providername="System.Data.SqlClient" />
      ...
    </connectionstrings>

Then, write the name of the connectionstring in the AppSetting MvcElmahDashboardConnectionName:

    <appSettings>
      <add key="MvcElmahDashboardConnectionName" value="whatever" />
      ...
    </appSettings>

3. Solving the 'Multiple types were found that match the controller named 'Home'' issue

You may now run your site (press F5) and navigate to the MvcElmahDashboard.

Chances are however that you get the following error:

Multiple types were found that match the controller named 'Home'. This can happen if...

To fix this issue, open the App_Start/RouteConfig.cs file and replace:

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );

by:

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
        namespaces: new String[] { "ElmahDashboardHostingApp.Controllers" }
    );

So, adding the marked code line.

That's it! You should now be up and running. See the next sections for more configuration options.

Cultural settings

By default, the ELMAH Dashboard takes the culture of the web request on the hosting server. You can however override this by forcing a culture in the Web.config using following AppSetting configuration:

    <appSettings>
      <add key="MvcElmahDashboardCulture" value="en-US" />
      ...
    </appSettings>

The value of this setting must be a valid CultureInfo code.

The Culture setting is used when rendering numbers and dates. I.e. the Culture setting determines wheter dates are rendered in monyh/day/year, day/month/year or year/month/day order.

The culture in use is displayed in the page footer of the ELMAH Dashboard.

User Agent & Geolocation information

Error details can provide further information about the User Agent (webbrowser, robot or crawler) and geolocation information about the remote address (IP address of the visitor).

User Agent information is configured by the MvcElmahDashboardUserAgentInfoProvider AppSetting. Remote Address information is configured by the MvcElmahDashboardRemoteAddressInfoProvider AppSetting.

Both settings consist of a set of key/value pairs with as keys: Caption, InfoUrl and ServiceUrl. The Remote Address setting can also take Latitude and Longitude keys.

The ServiceUrl must point to a service returning a flat JSON object. The Latitude and Longitude keys give the name of the JSON object properties containing the latitude and longitude respectively, which is used to display the location on a Google Map.

For instance, to configure the User Agent service using www.useragentstring.com:

    <appSettings>
      <add key="MvcElmahDashboardUserAgentInfoProvider"
      value="Caption=User Agent String.Com;InfoUrl=http://www.useragentstring.com/;ServiceUrl=http://www.useragentstring.com/?uas={value}&getJSON=all" />
      ...
    </appSettings>

To configure the Remote Address service using FreeGeoIP.net:

    <appSettings>
      <add key="MvcElmahDashboardRemoteAddressInfoProvider"
      value="Caption=FreeGeoIP.net;InfoUrl=http://freegeoip.net/;ServiceUrl=https://freegeoip.net/json/{value};Latitude=latitude;Longitude=longitude" />
      ...
    </appSettings>

To configure the Remote Address service using Geobytes.com:

    <appSettings>
      <add key="MvcElmahDashboardRemoteAddressInfoProvider"
      value="Caption=Geobytes.com;InfoUrl=http://www.geobytes.com/iplocator/;ServiceUrl=http://getcitydetails.geobytes.com/GetCityDetails?fqcn={value};Latitude=geobyteslatitude;Longitude=geobyteslongitude" />
      ...
    </appSettings>

Heartbeat service

ELMAH Dashboard's dashboard has a feature to autorefresh. If you use this while ELMAH Dashboard is running within the monitored site, you will be notified in the eventuality that your site would be down. (A dialog will appear and disappear autmatically once the site is up again).

But if the ELMAH Dashboard is hosted on a separate site, you may be montoring your site and see no new errors appear, without being aware that your site is down!

The Heartbeat service is meant to solve this problem. By configuring an URL in the web.config of the ELMAH Dashboard host, a box will appear on the dashboard showing whether the site is up or down.

Add an URL of your site, for instance the site's homepage URL in following AppsSetting:

    <appSettings>
      ...
      <add key="MvcElmahDashboardHeartBeatUrl" value="http://www.example.com/" />
      ...
    </appSettings>

By pointing to an URL that also performs a database lookup, you can monitor your database status in the same shot.

By default, this will poll your site once a minute. You can change the frequency with following AppSetting:

    <appSettings>
      ...
      <add key="MvcElmahDashboardHeartBeatInterval" value="00:00:30" />
      ...
    </appSettings>

Here, polling is done every 30 seconds. The pollings are initiated by the browser (no monitoring browser = no polling calls). But the pollings pass through the ELMAH Dashboard hosting web server to avoid cross site request issues. The hosting web server will hereby act as a proxy and prevent excessive polling to your monitored site by ignoring poll requests if a previous request is not older than half of the configured interval. Hence, if polling is set to 30 seconds, your monitored website will be checked at most once every 15 seconds. And the status reported in a specific monitoring browser could be at most 45 seconds outdated.

Also, if the ELMAH Dashboard hosting web server is down, polling will stop and signal an error condition.

When the ELMAH Dashboard is hosted within the site to monitor, this proxying or redirecting has no added value and can in some cases cause issues. You can then disable the redirection by setting the AppSettings MvcElmahDashboardHeartBeatDirectFromBrowser to true:

    <appSettings>
      ...
      <add key="MvcElmahDashboardHeartBeatDirectFromBrowser" value="true" />
      ...
    </appSettings>

Now, polling is done directly by the browser and the server cannot cache responses anymore. Having many polling browser sessions open simultaneously will therefore cause many polls.

Tips

Securing the ELMAH Dashboard

By default, the ELMAH Dashboard is not secured. You should therefore apply security before using it on public facing (and even internal) sites.

The easiest option is to add the following section to your web.config:

    <location path="MvcElmahDashboard">
      <system.web> 
        <authorization> 
          <allow roles="Administrators"/>
          <deny users="?"/>
          <deny users="*"/>
        </authorization>
      </system.web>
    </location>

This will allow only users with the 'Administrator' role on the ELMAH Dashboard. You will of course also have to configure (forms or another) authentication form.

More information.

Changing the path to your ELMAH Dashboard

By default, the ELMAH Dashboard is accessible under http://yoursite/MvcElmahDashboard.

You can change this path by changing the first path component in the area's route URL defined in the RegisterArea method of the MvcElmahDashboardAreaRegistration class in de Areas\MvcElmahDashboard folder:

public class MvcElmahDashboardAreaRegistration : AreaRegistration 
{
    public override string AreaName 
    {
        get 
        {
            return "MvcElmahDashboard";
        }
    }

    public override void RegisterArea(AreaRegistrationContext context) 
    {
        context.MapRoute(
            name: "MvcElmahDashboard_default",
            url: "MvcElmahDashboard/{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            namespaces: new string[] { "ElmahDashboardHostingApp.Areas.MvcElmahDashboard.Controllers" }
        );
    }
}

You don't need to change more. Don't change the AreaName property. (But do change the secured path form the previous tip and of course your links to the ELMAH Dashboard).

Adding indexes on your [ELMAH_Error] table

To speed up searches in the ELMAH error log, try to use as much as possible the Application / Host / Source / Type filters, espcially when using the searchbox to search on fulltext since fulltext search is an expensive operation.

To support the filters, it is also best to add indexes on the [ELMAH_Error] table, though note that indexes speed up retrieval but slow down inserts.

Following indexes can be added to the [ELMAH_Error] table:

    CREATE NONCLUSTERED INDEX [IX_ELMAH_Error_Application] ON [dbo].[ELMAH_Error] ([Application] ASC)
    GO
    CREATE NONCLUSTERED INDEX [IX_ELMAH_Error_Host] ON [dbo].[ELMAH_Error] ([Host] ASC)
    GO
    CREATE NONCLUSTERED INDEX [IX_ELMAH_Error_Type] ON [dbo].[ELMAH_Error] ([Type] ASC)
    GO
    CREATE NONCLUSTERED INDEX [IX_ELMAH_Error_Source] ON [dbo].[ELMAH_Error] ([Source] ASC)
    GO
    CREATE NONCLUSTERED INDEX [IX_ELMAH_Error_User] ON [dbo].[ELMAH_Error] ([User] ASC)
    GO
    CREATE NONCLUSTERED INDEX [IX_ELMAH_Error_TimeUtc] ON [dbo].[ELMAH_Error] ([TimeUtc] ASC)
    GO
    CREATE NONCLUSTERED INDEX [IX_ELMAH_Error_Sequence] ON [dbo].[ELMAH_Error] ([Sequence] ASC)
    GO

In addition, you should regularly reorganize and rebuild the indexes.