Class MongoDbAuditLogger
Audit logger that writes to MongoDB via a background channel for zero-latency impact. Resolves IAuditRepositoryCollection lazily to avoid DI issues in test environments.
public class MongoDbAuditLogger : BackgroundService, IHostedService, IDisposable, IAuditLogger
- Inheritance
-
MongoDbAuditLogger
- Implements
- Inherited Members
Constructors
MongoDbAuditLogger(IServiceProvider, ILogger<MongoDbAuditLogger>, IOptions<AuditOptions>)
public MongoDbAuditLogger(IServiceProvider serviceProvider, ILogger<MongoDbAuditLogger> logger, IOptions<AuditOptions> options = null)
Parameters
serviceProviderIServiceProviderloggerILogger<MongoDbAuditLogger>optionsIOptions<AuditOptions>
Methods
ExecuteAsync(CancellationToken)
This method is called when the IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.
protected override Task ExecuteAsync(CancellationToken stoppingToken)
Parameters
stoppingTokenCancellationTokenTriggered when StopAsync(CancellationToken) is called.
Returns
Remarks
See Worker Services in .NET for implementation guidelines.
Log(AuditEntry)
public void Log(AuditEntry entry)
Parameters
entryAuditEntry
QueryAsync(AuditQuery)
public Task<AuditQueryResult> QueryAsync(AuditQuery query)
Parameters
queryAuditQuery