Build status NuGet Samples

Logging to elmah.io from SignalR

Logging from SignalR is supported through our Elmah.Io.Extensions.Logging package. For details not included in this article, check out Logging from Microsoft.Extensions.Logging.

Start by installing the Elmah.Io.Extensions.Logging package:

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

In the Program.cs file, add a new using statement:

using Elmah.Io.Extensions.Logging;

Then configure elmah.io like shown here:

builder.Logging.AddElmahIo(options =>
{
    options.ApiKey = "API_KEY";
    options.LogId = new Guid("LOG_ID");
});
builder.Logging.AddFilter<ElmahIoLoggerProvider>(null, LogLevel.Warning);

Replace API_KEY with your API key (Where is my API key?) and LOG_ID (Where is my log ID?) with the log Id of the log you want to log to.

The code only logs Warning, Error, and Fatal messages. To change that you can change the LogLevel filter specified in the line calling the AddFilter method. You may also need to change log levels for SignalR itself:

logging.AddFilter("Microsoft.AspNetCore.SignalR", LogLevel.Debug);
logging.AddFilter("Microsoft.AspNetCore.Http.Connections", LogLevel.Debug);

Be aware that changing log levels to Debug or lower will cause a lot of messages to be stored in elmah.io. Log levels can be specified through the appsettings.json file as with any other ASP.NET Core application. Check out appsettings.json configuration for more details.


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