ElmahLog.NetCore.Sql 3.0.0

dotnet add package ElmahLog.NetCore.Sql --version 3.0.0
                    
NuGet\Install-Package ElmahLog.NetCore.Sql -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ElmahLog.NetCore.Sql" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ElmahLog.NetCore.Sql" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ElmahLog.NetCore.Sql" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ElmahLog.NetCore.Sql --version 3.0.0
                    
#r "nuget: ElmahLog.NetCore.Sql, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ElmahLog.NetCore.Sql@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ElmahLog.NetCore.Sql&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ElmahLog.NetCore.Sql&version=3.0.0
                    
Install as a Cake Tool

This project is licensed under the terms of the Apache License 2.0.

ElmahLog.NetCore

ELMAH for ASP.NET Core (.NET Standard 2.0 / .NET 8+)

Forked from ElmahCore/ElmahCore and republished as ElmahLog.NetCore v3.0.0 with updated dependencies, security fixes, and .NET 8/10 support.

Elmah.Core UI

Installation

Install the main NuGet package:

dotnet add package ElmahLog.NetCore

Optional storage providers:

Package Storage
ElmahLog.NetCore.Sql MS SQL Server
ElmahLog.NetCore.MySql MySQL
ElmahLog.NetCore.Postgresql PostgreSQL

Supported Frameworks

  • .NET Standard 2.0 (compatible with .NET Framework 4.6.1+, .NET Core 2.0+)
  • .NET 8.0 and above

Simple Usage

Program.cs (minimal hosting, .NET 6+):

builder.Services.AddElmah();  // in service registration
app.UseElmah();               // in middleware pipeline

Startup.cs (traditional):

// ConfigureServices
services.AddElmah();

// Configure - must be after UseExceptionHandler / UseDeveloperExceptionPage
app.UseElmah();

Default Elmah path: ~/elmah

Change URL Path

services.AddElmah(options => options.Path = "errors")

Restrict Access

services.AddElmah(options =>
{
    options.OnPermissionCheck = context => context.User.Identity.IsAuthenticated;
});

Note: app.UseElmah() must come after app.UseAuthentication() and app.UseAuthorization().

Change Error Log Type

Implement your own:

class MyErrorLog : ErrorLog { ... }

Built-in options:

  • MemoryErrorLog — in-memory (default)
  • XmlFileErrorLog — XML files on disk
  • SqlErrorLog — MS SQL Server (requires ElmahLog.NetCore.Sql)
  • MySqlErrorLog — MySQL (requires ElmahLog.NetCore.MySql)
  • PgsqlErrorLog — PostgreSQL (requires ElmahLog.NetCore.Postgresql)
services.AddElmah<XmlFileErrorLog>(options =>
{
    options.LogPath = "~/log"; // or options.LogPath = @"C:\errors";
});
services.AddElmah<SqlErrorLog>(options =>
{
    options.ConnectionString = "connection_string";
    options.SqlServerDatabaseSchemaName = "Errors";   // default: dbo
    options.SqlServerDatabaseTableName  = "ElmahError"; // default: ELMAH_Error
});

Raise Exception Manually

public IActionResult Test()
{
    HttpContext.RaiseError(new InvalidOperationException("Test"));
    ...
}

Microsoft.Extensions.Logging Support

Since v2.0, ElmahLog.NetCore integrates with Microsoft.Extensions.Logging.

Logging

Source Preview

Since v2.0.1 — configure source file paths:

services.AddElmah(options =>
{
    options.SourcePaths = new[]
    {
        @"D:\src\MyProject",
        @"D:\src\MyProject.Mvc"
    };
});

Log the Request Body

Since v2.0.5, ElmahLog.NetCore can log the HTTP request body.

SQL Query Logging

Since v2.0.6, ElmahLog.NetCore intercepts and logs SQL commands via DiagnosticSource.

SQL Log

Method Parameter Logging

Since v2.0.6:

using ElmahCore;

public void TestMethod(string p1, int p2)
{
    this.LogParams((nameof(p1), p1), (nameof(p2), p2));
    // ...
}

Parameters

Developer Exception Page

if (app.Environment.IsDevelopment())
{
    // app.UseDeveloperExceptionPage();
    app.UseElmahExceptionPage();
}

Notifiers

Implement IErrorNotifier or IErrorNotifierWithId and register:

services.AddElmah<XmlFileErrorLog>(options =>
{
    options.Notifiers.Add(new ErrorMailNotifier("Email", emailOptions));
});

Filters

XML-based or code-based error filtering:

services.AddElmah<XmlFileErrorLog>(options =>
{
    options.FiltersConfig = "elmah.xml";
    options.Filters.Add(new MyFilter());
});

XML filter example:

<?xml version="1.0" encoding="utf-8" ?>
<elmah>
  <errorFilter>
    <notifiers>
      <notifier name="Email"/>
    </notifiers>
    <test>
      <and>
        <greater binding="HttpStatusCode" value="399" type="Int32" />
        <lesser  binding="HttpStatusCode" value="500" type="Int32" />
      </and>
    </test>
  </errorFilter>
</elmah>

See more at elmah.github.io.

Search and Filters

Since v2.2.0 — full-text search and multi-column filtering.

Filters 1 Filters 2 Filters 3

Currently supported by Memory and XmlFile error logs only.

Demo Projects

Project Framework Description
Demos/ElmahCore.DemoCore8 .NET 8 Startup.cs + SqlErrorLog
Demos/ElmahCore.DemoCore10 .NET 10 Minimal hosting + XmlFileErrorLog + Notifiers + Filters

License

Apache License 2.0 — Copyright 2018 ElmahCore, Portions Copyright © 2026 Lawrence Shen

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 120 5/5/2026