Package Description
$ dotnet add package Audit.NET.ChannelsChannel provider for Audit.NET library (An extensible framework to audit executing operations in .NET).
Store the audit events in memory in a bounded or unbounded Channel (System.Threading.Channels).
Audit events are produced to the channel for a consumer to retrieve.
NuGet Package To install the package run the following command on the Package Manager Console:
PM> Install-Package Audit.NET.Channels
Please see the Audit.NET Readme
Set the static Audit.Core.Configuration.DataProvider property to set the Channel data provider, or call the UseInMemoryChannel method on the fluent configuration.
This should be done before any AuditScope creation, i.e. during application startup.
For example:
Audit.Core.Configuration.DataProvider = new ChannelDataProvider(Channel.CreateUnbounded<AuditEvent>());
Or by using the fluent configuration API:
Audit.Core.Configuration.Setup()
.UseInMemoryChannelProvider(channel => channel.Bounded(100));
The ChannelDataProvider allows to consume the events by providing a TakeAsync and TryTakeAsync methods.
For example:
// Start up
Audit.Core.Configuration.DataProvider = new ChannelDataProvider(c => c.Unbounded());
// Consumer
var dataProvider = Audit.Core.Configuration.DataProviderAs<ChannelDataProvider>();
while (!cancellationToken.IsCancellationRequested)
{
var auditEvent = await dataProvider.TakeAsync(cancellationToken);
// Handle the auditEvent...
Handle(auditEvent);
}
Entity Framework Extensions and Dapper Plus are major sponsors and are proud to contribute to the development of Audit.NET
Combine the power of auditing with the speed of Bulk Operations to get the best of both worlds — audit and performance.