Serilog storage provider for Audit.NET library (An extensible framework to audit executing operations in .NET).
Store the audit events using Serilog™.
NuGet Package
To install the package, run the following command on the Package Manager Console:
PM> Install-Package Audit.NET.Serilog
Please see the Audit.NET Readme
To set the Serilog data provider globally, call the UseSerilog()
method on the fluent configuration API, for example:
Audit.Core.Configuration.Setup()
.UseSerilog();
You can also configure the provider settings by using the fluent API, for example:
Audit.Core.Configuration.Setup()
.UseSerilog(config => config
.Logger(LogManager.GetLogger(typeof(MyClass)))
.LogLevel(LogLevel.Debug)
.Message(auditEvent => auditEvent.ToJson()));
The Logger and LogLevel settings can be configured as a function of the audit event, for example:
Audit.Core.Configuration.Setup()
.UseSerilog(config => config
.Logger(ev => LogManager.GetLogger(ev.EventType))
.LogLevel(ev => ev.Environment.Exception != null ? LogLevel.Fatal : LogLevel.Info));
Logger
: Indicates the Serilog ILogger logger instance to use. Default is obtained by using the audit event typeLogManager.GetLogger(auditEvent.GetType())
.LogLevel
: Indicates the log level to use (debug, info, warn, error or fatal). Default is Info unless there is an exception, in which case it logs as Error.Message
: Indicates the textual message to log. Default is the AuditEvent JSON including the EventId as a custom field.