DKNet.EfCore.AuditLogs 10.1.18

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

DKNet.EfCore.AuditLogs

A DKNet.EfCore.Hooks-based SaveChanges interceptor that captures a structured, field-level audit trail of entity changes — with automatic redaction of likely-sensitive values — and hands finished batches to your own publisher(s).

Install

dotnet add package DKNet.EfCore.AuditLogs

Features

  • Automatic before/after-SaveChanges capture of Created/Updated/Deleted entities implementing IAuditedProperties, with per-field old/new value diffs.
  • Built-in redaction of likely-sensitive properties (passwords, tokens, connection strings, SecureString, …), overridable per-property via [AuditLog] and forced via [SensitiveData] from DKNet.EfCore.Abstractions.
  • Pluggable IAuditLogPublisher extension point — ship audit batches to a database, queue, log sink, or anywhere else; multiple publishers per DbContext are supported.
  • Configurable scope: audit every entity or only those explicitly marked [AuditLog], and capture every property or only allow-listed ones.

Quick start

using DKNet.EfCore.AuditLogs;
using DKNet.EfCore.Hooks;

// 1. Register the DbContext through the hook-aware overload.
services.AddDbContextWithHook<AppDbContext>((provider, options) =>
    options.UseSqlServer(connectionString));

// 2. Register the audit hook plus a publisher, keyed to AppDbContext.
services.AddEfCoreAuditLogs<AppDbContext, MyAuditLogPublisher>();

// 3. Implement the publisher.
public sealed class MyAuditLogPublisher : IAuditLogPublisher
{
    public Task PublishAsync(IEnumerable<AuditLogEntry> logs, CancellationToken cancellationToken = default)
    {
        foreach (var log in logs)
            Console.WriteLine($"[{log.Action}] {log.EntityName} by {log.UpdatedBy ?? log.CreatedBy}");
        return Task.CompletedTask;
    }
}

Customisation reference

AddEfCoreAuditHook<TDbContext> and AddEfCoreAuditLogs<TDbContext, TPublisher> take the same two optional arguments. They are fixed at registration time for the whole application — there is no per-save or per-entity override, and no options class to reconfigure afterwards.

Option Type Default Effect
behaviour AuditLogBehaviour IncludeAllAuditedEntities IncludeAllAuditedEntities audits every IAuditedProperties entity not marked [IgnoreAuditLog]. OnlyAttributedAuditedEntities audits only entities marked [AuditLog] at class level.
propertyPolicy AuditPropertyPolicy RedactSensitive RedactSensitive captures every non-ignored property, replacing sensitive-looking values with ***REDACTED***. OnlyAttributedProperties captures only properties marked [AuditLog].

Attribute-level control comes from DKNet.EfCore.Abstractions:

Attribute On Effect
[IgnoreAuditLog] class or property Excluded unconditionally, whatever the behaviour and policy.
[AuditLog] class Opts the entity in under OnlyAttributedAuditedEntities.
[AuditLog] property Forces plaintext past the sensitive-name patterns, and allow-lists it under OnlyAttributedProperties.
[SensitiveData] property Always redacted, even alongside [AuditLog].

The built-in sensitive-name fragments are password, secret, token, apikey, api_key, ssn, socialsecuritynumber, creditcard, cvv, pin, connectionstring, privatekey, passphrase, accesskey and salt (case-insensitive substring match), plus any property typed SecureString. The list is not configurable — use [SensitiveData] to add to it and [AuditLog] to opt out of it per property.

An entity that does not implement IAuditedProperties is skipped before any attribute is inspected.

Full documentation: https://github.com/baoduy/DKNet/blob/main/docs/EfCore/DKNet.EfCore.AuditLogs.md

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 (1)

Showing the top 1 NuGet packages that depend on DKNet.EfCore.AuditLogs:

Package Downloads
DKNet.EfCore.DataAuthorization

DKNet is an enterprise-grade .NET library collection focused on advanced EF Core extensions, dynamic predicate building, and the Specification pattern. It provides production-ready tools for building robust, type-safe, and testable data access layers, including dynamic LINQ support, LinqKit integration. Designed for modern cloud-native applications, DKNet enforces strict code quality, async best practices, and full documentation for all public APIs. Enterprise-grade .NET library suite for modern application development, featuring advanced EF Core extensions (dynamic predicates, specifications, LinqKit), robust Domain-Driven Design (DDD) patterns, and domain event support. DKNet empowers scalable, maintainable, and testable solutions with type-safe validation, async/await, XML documentation, and high code quality standards. Ideal for cloud-native, microservices, and enterprise architectures.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.1.29 0 9/17/2026
10.1.28 0 9/17/2026
10.1.27 23 9/16/2026
10.1.26 40 9/16/2026
10.1.25 32 9/16/2026
10.1.24 81 9/11/2026
10.1.23 82 9/11/2026
10.1.22 84 9/11/2026
10.1.21 83 9/11/2026
10.1.20 90 9/9/2026
10.1.19 182 9/3/2026
10.1.18 84 9/3/2026
10.1.17 92 9/3/2026
10.1.16 93 9/3/2026
10.1.15 130 9/1/2026
10.1.14 82 9/1/2026
10.1.13 94 8/31/2026
10.1.12 92 8/25/2026
10.1.11 102 8/24/2026
10.1.10 100 8/22/2026
Loading failed