Audit Trail Installation
Prerequisites
- .NET 8 or later
- Entity Framework Core 8+ (for EF Core backend)
- Sufficient storage space for audit records (plan for retention requirements)
Package Installation
Core Audit Trail Package
The core package provides the middleware and base abstractions:
dotnet add package Hermodr.AuditTrail
Storage Backend Packages
Choose one or more storage backends based on your needs:
NDJSON Backend (File-Based, Recommended for Most Scenarios)
dotnet add package Hermodr.AuditTrail.NDJson
Entity Framework Core Backend (Database-Backed)
dotnet add package Hermodr.AuditTrail.EntityFramework
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
Replace Sqlite with your actual provider (SqlServer, Npgsql, PostgreSQL, etc.).
Package Overview
| Package | Purpose | Required |
|---|---|---|
Hermodr.AuditTrail | Core middleware and abstractions | ✅ Yes |
Hermodr.AuditTrail.NDJson | NDJSON file-based backend | For file storage |
Hermodr.AuditTrail.EntityFramework | EF Core database backend | For database storage |
Microsoft.EntityFrameworkCore.* | Database provider | For EF Core backend |
What's Included
Core Package
AuditTrailMiddleware— Middleware that records every published eventIAuditTrailWriter— Write interface for audit entriesIAuditTrailReader— Read interface for querying audit entriesAuditTrailEntry— Data contract for stored audit records
NDJSON Package
NdJsonAuditTrail— NDJSON file-based implementationAuditTrailStreamQuery— Stream-based query API- File rolling and retention management
IFileSystemabstraction for pluggable storage
EF Core Package
AuditTrailDbContext— EF Core context with audit entitiesDbAuditTrailEntry— Entity mappingEntityAuditTrailRepository— Repository implementation- LINQ query support
Storage Requirements
NDJSON Backend
- Disk space: Plan for ~1-10 MB per 10,000 events (depends on event size)
- File retention: Default keeps 30 files, configurable
- I/O: Sequential writes, concurrent reads supported
EF Core Backend
- Database: Requires relational database (SQL Server, PostgreSQL, SQLite, etc.)
- Table size: Grows linearly with event count
- Indexing: Recommended on
EventType,Timestamp,Subjectcolumns - Retention: Implement archival/deletion policy for compliance
Next Steps
After installation:
- Concepts — Understand audit trail scope and use cases
- NDJSON Backend — Configure file-based storage
- Querying — Learn to read and filter audit entries
- Examples — See real-world usage patterns