ElmahCoreX 2.2.7

There is a newer version of this package available.
See the version list below for details.
dotnet add package ElmahCoreX --version 2.2.7
                    
NuGet\Install-Package ElmahCoreX -Version 2.2.7
                    
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="ElmahCoreX" Version="2.2.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ElmahCoreX" Version="2.2.7" />
                    
Directory.Packages.props
<PackageReference Include="ElmahCoreX" />
                    
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 ElmahCoreX --version 2.2.7
                    
#r "nuget: ElmahCoreX, 2.2.7"
                    
#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 ElmahCoreX@2.2.7
                    
#: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=ElmahCoreX&version=2.2.7
                    
Install as a Cake Addin
#tool nuget:?package=ElmahCoreX&version=2.2.7
                    
Install as a Cake Tool

Build Status Latest Version Version Pre-release Last Commit

License Contributors

About

This is a fork of the ElmahCore project, with changes for PR's that were sitting idle. It should be an almost slot in replacement for ElmahCore v2.1.2.

See changelog.md for any further changes from v2.1.2

The interfaces and namespaces have been kept the same.

License

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

Frontend UI

The front end has been completely rewritten in Vue 3 with a modern, minimalist design. The source code for the SPA is fully available in the src/ui folder. It can be built via npm install and npm run build which will output the compiled assets to the ElmahCore.Mvc/wwwroot folder as embedded resources.

Using ElmahCore

ELMAH for Net Core 10

Add NuGet package ElmahCoreX

Simple usage

// Startup.cs
services.AddElmah() //in ConfigureServices
// ...
app.UseElmah(); // in Configure, must be positioned after initializing other exception handlers
                // such as UseExceptionHandler and UseDeveloperExceptionPage

Default ELMAH endpoint path ~/elmah.

Change URL path

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

Restrict access to the ELMAH URL

services.AddElmah(options =>
{
    options.OnPermissionCheck = context => context.User.Identity.IsAuthenticated;
});
// startup.cs
app.UseAuthentication();
app.UseAuthorization();
//...
app.UseElmah(); // needs to be positioned after `UseAuthentication` and `UseAuthorization`

or the user will be redirected to the sign-in screen even if they are authenticated.

Change Error Log type

You can implement a custom error log adapter to write logs to alternate locations.

public class MyErrorLog: ErrorLog {
    // Implement ErrorLog
}    

The ErrorLog adapters available:

  • MemoryErrorLog – store errors in memory (by default)
  • XmlFileErrorLog – store errors in XML files.
  • SqlErrorLog - store errors in MS SQL (add reference to ElmahCoreEx.Sql)
  • MysqlErrorLog - store errors in MySQL (add reference to ElmahCoreEx.MySql)
  • PgsqlErrorLog - store errors in PostgreSQL (add reference to ElmahCoreEx.Postgresql)

Example to configure for XML:

services.AddElmah<XmlFileErrorLog>(options =>
{
  options.LogPath = "~/log"; // OR options.LogPath = "с:\errors";
});

Example to configure For MSSQL

services.AddElmah<SqlErrorLog>(options =>
{
  options.ConnectionString = "connection_string";
  options.SqlServerDatabaseSchemaName = "Errors"; // Defaults to dbo if not set
  options.SqlServerDatabaseTableName = "ElmahError"; // Defaults to ELMAH_Error if not set
});

Disable Full XML Logging

For high-volume applications, you can disable storing the full XML representation of errors in the database to reduce storage requirements. When disabled, a minimal placeholder XML is stored instead. The basic error fields (type, message, source, user, time, statusCode) are still stored in dedicated database columns.

services.AddElmah<SqlErrorLog>(options =>
{
  options.ConnectionString = "connection_string";
  options.LogAllXml = false; // Disable full XML storage
});

This option works with SqlErrorLog, MySqlErrorLog, and PgsqlErrorLog. Default is true for backward compatibility.

Raise exception

To raise a custom exception to log:

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

Microsoft.Extensions.Logging support

ElmahCoreEx support Microsoft.Extensions.Logging

Source Preview

ElmahCoreEx support source preview. Add paths to source files example:

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

Logging request body

V2.0.5+ ElmahCoreEx can log the request body.

Logging SQL request body

v2.0.6+ ElmahCoreEx can log the SQL request body.

Logging method parameters

V2.0.6+ ElmahCoreEx can log method parameters.

using ElmahCore;
...

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

Using UseElmahExceptionPage

You can replace UseDeveloperExceptionPage to UseElmahExceptionPage

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

Using Notifiers

You can create custom notifiers by implementing IErrorNotifier or IErrorNotifierWithId interface and add notifier to Elmah options:

services.AddElmah<XmlFileErrorLog>(options =>
{
    options.Path = @"errors";
    options.LogPath = "~/logs";
    options.Notifiers.Add(new ErrorMailNotifier("Email",emailOptions));
});

Each notifier must have a unique name.

Using Filters

You can use Elmah XML filter configuration in a separate file, create and add custom filters:

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

Custom filter must implement IErrorFilter. An XML filter config 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 here

JavaScript filters have not been implemented

Attach notifiers to the errorFilter node if you wish to avoid sending notifications. Errors that are filtered will be recorded but not dispatched.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
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
2.2.9 106 6/22/2026
2.2.8 89 6/21/2026
2.2.7 113 6/15/2026
2.2.5 98 6/14/2026
2.2.4 89 6/14/2026
2.2.3 110 6/14/2026
2.2.2 101 6/14/2026
2.2.1 89 6/13/2026
2.2.0 93 6/13/2026