Headless.AuditLog.Abstractions
0.4.15
dotnet add package Headless.AuditLog.Abstractions --version 0.4.15
NuGet\Install-Package Headless.AuditLog.Abstractions -Version 0.4.15
<PackageReference Include="Headless.AuditLog.Abstractions" Version="0.4.15" />
<PackageVersion Include="Headless.AuditLog.Abstractions" Version="0.4.15" />
<PackageReference Include="Headless.AuditLog.Abstractions" />
paket add Headless.AuditLog.Abstractions --version 0.4.15
#r "nuget: Headless.AuditLog.Abstractions, 0.4.15"
#:package Headless.AuditLog.Abstractions@0.4.15
#addin nuget:?package=Headless.AuditLog.Abstractions&version=0.4.15
#tool nuget:?package=Headless.AuditLog.Abstractions&version=0.4.15
Headless.AuditLog.Abstractions
Defines the property-level audit log contracts for tracking entity mutations and explicit business events.
Problem Solved
Provides a provider-agnostic audit log API for capturing field-level entity changes and explicit events (PII reveals, cross-tenant access, etc.) without binding consumers to any specific storage implementation.
Key Features
IAuditTracked- Marker interface; entities implementing it are automatically audited on SaveChangesAuditIgnoreAttribute- Excludes a property (or entire entity) from change captureAuditSensitiveAttribute- Marks a property as PII/secret; value is handled per configured strategySensitiveDataStrategy-Redact(replace with"***"),Exclude(omit entirely), orTransform(custom function)AuditLogOptions- Master enable/disable,AuditByDefaultmode, per-entity/property filters, configurable default exclusions, sensitive-value transformerIAuditLog<TContext>- Explicit logging of non-mutation events (reads, reveals, failures); theTContexttype-arg binds the logger to a specific persistence context so multi-context applications resolve a distinct logger per owning contextIAuditLogStore- Storage abstraction called by the change-tracking pipeline.Save/SaveAsyncnow take the saving context (theDbContextrunningSaveChanges) on every call and return oneIAuditLogStoreEntryhandle per audit row added to that context (empty list = nothing added, orchestrator skips the audit commit step)IAuditLogStoreEntry- Provider-owned handle for an audit row added to the persistence context; the orchestrator callsDiscardPendingChanges()on failure andReleaseAfterCommit()after success. Implementations must be idempotent, andReleaseAfterCommit()must not undo committed audit rowsIReadAuditLog<TContext>- Query abstraction for reading audit entries back without coupling callers to EF types; theTContexttype-arg binds the reader to a specific persistence context, mirroringIAuditLog<TContext>IAuditChangeCapture- Scans ChangeTracker entries and producesAuditLogEntryDatarecords
Installation
dotnet add package Headless.AuditLog.Abstractions
Usage
Entity opt-in
public class Patient : AggregateRoot<Guid>, IAuditTracked
{
public string Name { get; set; } = "";
[AuditSensitive]
public string NationalId { get; set; } = "";
[AuditIgnore]
public DateTime LastComputedAt { get; set; }
}
Registration
services.AddHeadlessAuditLog(o =>
{
o.SensitiveDataStrategy = SensitiveDataStrategy.Redact;
});
This package registers options only. Add
Headless.AuditLog.EntityFrameworkfor the EF Core implementation that wires up storage and change capture.
Configuration
| Option | Default | Description |
|---|---|---|
IsEnabled |
true |
Master switch; false disables all capture |
AuditByDefault |
false |
When true, audits every entity unless [AuditIgnore] is present |
SensitiveDataStrategy |
Redact |
Global strategy for [AuditSensitive] properties |
SensitiveValueTransformer |
null |
Required whenever the effective strategy is Transform; must be a pure, synchronous function |
EntityFilter |
null |
Predicate returning true to exclude a type; first result is cached per type for the capture service lifetime |
PropertyFilter |
null |
Predicate returning true to exclude a property; first result is cached per (Type, propertyName) for the capture service lifetime |
DefaultExcludedProperties |
Framework-managed names | Default property names skipped during change capture; consumers can add/remove entries |
Important Notes
AddHeadlessAuditLogvalidates the globalSensitiveDataStrategy.Transformconfiguration and fails options resolution when noSensitiveValueTransformeris configured.- If a property explicitly uses
[AuditSensitive(SensitiveDataStrategy.Transform)], the first capture attempt throws anOptionsValidationExceptionunlessSensitiveValueTransformeris configured. EntityFilterandPropertyFilterresults are cached after first evaluation, so predicates must be pure and deterministic.AuditLogEntryData.OldValuesandNewValuesmay containJsonElementvalues after provider round-trips; useJsonElementAPIs such asGetDecimal()for typed access.EntityIdstays a plain string for single-column keys; composite keys are serialized as a JSON string array.IpAddressandUserAgentare not auto-populated by the built-in EF change-capture pipeline; set them explicitly throughIAuditLog.LogAsyncor a custom capture implementation.
Dependencies
Headless.HostingMicrosoft.Extensions.DependencyInjection.AbstractionsMicrosoft.Extensions.Options
Side Effects
None. This is an abstractions package.
| 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
- CommunityToolkit.HighPerformance (>= 8.4.2)
- FluentValidation (>= 12.1.1)
- Headless.Hosting (>= 0.4.15)
- Humanizer.Core (>= 3.0.10)
- IdGen (>= 3.0.7)
- JetBrains.Annotations (>= 2025.2.4)
- libphonenumber-csharp (>= 9.0.30)
- Microsoft.Bcl.TimeProvider (>= 10.0.8)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.8)
- Microsoft.Extensions.DependencyInjection (>= 10.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Hosting (>= 10.0.8)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Logging (>= 10.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Logging.Console (>= 10.0.8)
- Microsoft.Extensions.Options (>= 10.0.8)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.8)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.8)
- morelinq (>= 4.4.0)
- Nito.AsyncEx (>= 5.1.2)
- Nito.Disposables (>= 2.5.0)
- Polly.Core (>= 8.6.6)
- Scrutor (>= 7.0.0)
- System.Reactive (>= 6.1.0)
- TimeZoneConverter (>= 7.2.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Headless.AuditLog.Abstractions:
| Package | Downloads |
|---|---|
|
Headless.AuditLog.EntityFramework
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.