DKNet.EfCore.AuditLogs
10.1.18
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
<PackageReference Include="DKNet.EfCore.AuditLogs" Version="10.1.18" />
<PackageVersion Include="DKNet.EfCore.AuditLogs" Version="10.1.18" />
<PackageReference Include="DKNet.EfCore.AuditLogs" />
paket add DKNet.EfCore.AuditLogs --version 10.1.18
#r "nuget: DKNet.EfCore.AuditLogs, 10.1.18"
#:package DKNet.EfCore.AuditLogs@10.1.18
#addin nuget:?package=DKNet.EfCore.AuditLogs&version=10.1.18
#tool nuget:?package=DKNet.EfCore.AuditLogs&version=10.1.18
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-
SaveChangescapture of Created/Updated/Deleted entities implementingIAuditedProperties, 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]fromDKNet.EfCore.Abstractions. - Pluggable
IAuditLogPublisherextension point — ship audit batches to a database, queue, log sink, or anywhere else; multiple publishers perDbContextare 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 | Versions 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. |
-
net10.0
- DKNet.EfCore.Abstractions (>= 10.1.18)
- DKNet.EfCore.Hooks (>= 10.1.18)
- Microsoft.EntityFrameworkCore (>= 10.0.11)
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 |
|---|---|---|
| 10.1.19 | 56 | 9/3/2026 |
| 10.1.18 | 51 | 9/3/2026 |
| 10.1.17 | 60 | 9/3/2026 |
| 10.1.16 | 61 | 9/3/2026 |
| 10.1.15 | 103 | 9/1/2026 |
| 10.1.14 | 64 | 9/1/2026 |
| 10.1.13 | 80 | 8/31/2026 |
| 10.1.12 | 84 | 8/25/2026 |
| 10.1.11 | 94 | 8/24/2026 |
| 10.1.10 | 91 | 8/22/2026 |
| 10.1.9 | 104 | 8/22/2026 |
| 10.1.8 | 93 | 8/21/2026 |
| 10.1.7 | 101 | 8/21/2026 |
| 10.1.6 | 91 | 8/21/2026 |
| 10.1.5 | 152 | 8/20/2026 |
| 10.1.4 | 89 | 8/20/2026 |
| 10.1.3 | 90 | 8/19/2026 |
| 10.1.2 | 88 | 8/19/2026 |
| 10.1.1 | 86 | 8/19/2026 |
| 10.0.36 | 90 | 8/18/2026 |