Logging to elmah.io from Piranha CMS

Piranha CMS is a popular headless CMS written in ASP.NET Core. elmah.io works with Piranha CMS out of the box. This document contains a quick installation guide for setting up elmah.io logging in Piranha CMS. For the full overview of logging from ASP.NET Core, check out Logging to elmah.io from ASP.NET Core.

To start logging to elmah.io, install the Elmah.Io.AspNetCore NuGet package:

Install-Package Elmah.Io.AspNetCore
dotnet add package Elmah.Io.AspNetCore
<PackageReference Include="Elmah.Io.AspNetCore" Version="5.*" />
paket add Elmah.Io.AspNetCore

Then modify your Startup.cs file:

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        // ...
        services.AddElmahIo(o =>
        {
            o.ApiKey = "API_KEY";
            o.LogId = new Guid("LOG_ID");
        });
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        // ...
        app.UseElmahIo();
        // ...
    }
}

Replace API_KEY with your API key (Where is my API key?) and LOG_ID with the id of the log (Where is my log ID?) where you want errors logged.

Make sure to call the UseElmahIo-method after setting up other middleware handling exceptions (like UseDeveloperExceptionPage), but before the call to UsePiranha.

To use structured logging and the ILogger interface with Piranha CMS and elmah.io, set up Microsoft.Extensions.Logging as explained here: Logging to elmah.io from Microsoft.Extensions.Logging.


This article was brought to you by the elmah.io team. elmah.io is the best error management system for .NET web applications. We monitor your website, alert you when errors start happening, and help you fix errors fast.

See how we can help you monitor your website for crashes Monitor your website