Audit.NET is designed with a pluggable architecture that separates the collection of audit data from its storage. While the core library includes several built-in providers (such as File, EventLog, and InMemory), the majority of storage integrations are provided via external NuGet packages. These providers allow you to persist AuditEvent objects to various relational databases, NoSQL document stores, cloud storage services, and messaging systems.
Most external storage providers follow a consistent implementation pattern to ensure ease of use and predictability:
IAuditConfigurator to provide a domain-specific fluent API within Configuration.Setup().AuditDataProvider base class src/Audit.NET/Providers/AuditDataProvider.cs7 or the IAuditDataProvider interface, overriding InsertEvent, ReplaceEvent, and where applicable, GetEvent.InsertEventAsync) to support non-blocking I/O src/Audit.NET.RavenDB/Providers/RavenDbDataProvider.cs112-121AuditEvent into JSON using the configured IJsonAdapter (System.Text.Json or Newtonsoft.Json) before storage src/Audit.NET.RavenDB/Providers/RavenDbDataProvider.cs87-93The following diagram illustrates how the AuditScope interacts with different categories of data providers during the audit lifecycle.
Audit Data Provider Flow
Sources: src/Audit.NET/Audit.NET.csproj1-54 CODE_COVERAGE.md25
These providers are used for storing audit trails in traditional SQL databases. They typically support a "Hybrid" storage approach: storing the entire audit event as a JSON blob in one column, while extracting specific metadata into dedicated relational columns via CustomColumns.
SqlDataProvider provided by the Audit.NET.SqlServer package src/Audit.NET.SqlServer/Audit.NET.SqlServer.csproj16PostgreSqlDataProvider for flexible JSONB storage.MySqlDataProvider via the Audit.NET.MySql package src/Audit.NET.MySql/Audit.NET.MySql.csproj16For details on schema setup and column mapping, see Relational Database Providers.
NoSQL providers are ideal for audit trails because AuditEvent objects are naturally hierarchical and schema-less.
MongoDataProvider to store events as BSON documents. It includes logic to handle BSON element naming constraints via FixDocumentElementNames CODE_COVERAGE.md25AzureCosmosDataProvider supports the latest Azure Cosmos DB client.RavenDbDataProvider which can be configured with a custom IDocumentStore src/Audit.NET.RavenDB/Providers/RavenDbDataProvider.cs33-45DynamoDataProvider.For details on document mapping and querying, see NoSQL & Document Database Providers.
These providers leverage Azure's managed storage services for scalability and durability.
AzureTableDataProvider to translate audit events into TableEntity rows test/Audit.AzureStorageTables.UnitTest/AzureTableDataProviderIntegrationTests.cs23-29AzureEventHubsDataProvider test/Audit.AzureEventHubs.UnitTest/AzureEventHubsTests.cs119-125For details on Azure-specific configuration, see Azure Cloud Storage Providers.
Messaging providers allow for asynchronous, decoupled processing of audit events.
RedisDataProvider, including AsString, AsList, AsHash, AsSortedSet, AsPubSub, and AsStream test/Audit.Redis.UnitTest/RedisTests.cs28-33KafkaDataProvider.UdpDataProvider src/Audit.NET.Udp/Audit.NET.Udp.csproj4-6ChannelDataProvider.For details on transport modes and messaging patterns, see Messaging & Streaming Providers.
These providers bridge Audit.NET with existing application logging infrastructure.
EventLogDataProvider CODE_COVERAGE.md25For details on log formatting and deserialization, see Logging Framework Providers.
The following diagram maps logical storage categories to the specific primary data provider classes and their respective project namespaces.
Provider Class Mapping
Sources: src/Audit.NET/Audit.NET.csproj26 src/Audit.NET.SqlServer/Audit.NET.SqlServer.csproj26 src/Audit.NET.MongoDB/Audit.NET.MongoDB.csproj22 src/Audit.NET.Redis/Audit.NET.Redis.csproj26 CODE_COVERAGE.md25
Refresh this wiki
This wiki was recently refreshed. Please wait 7 days to refresh again.