Table of Contents

Class DefaultAuditLogger

Namespace
Excalibur.AuditLogging
Assembly
Excalibur.AuditLogging.dll

Default implementation of IAuditLogger that delegates to an IAuditStore.

public sealed class DefaultAuditLogger : IAuditLogger
Inheritance
DefaultAuditLogger
Implements
Inherited Members

Remarks

The audit logger is fail-closed: when the underlying IAuditStore fails to persist an event, the failure is surfaced to the caller as an AuditPersistenceException rather than swallowed, so an unrecorded compliance event is never mistaken for a durably stored one. Callers that require availability over durability must catch that exception and apply their own policy.

It also provides hash-chain integrity verification and event validation before storage.

Constructors

DefaultAuditLogger(IAuditStore, ILogger<DefaultAuditLogger>)

Initializes a new instance of the DefaultAuditLogger class.

public DefaultAuditLogger(IAuditStore auditStore, ILogger<DefaultAuditLogger> logger)

Parameters

auditStore IAuditStore

The audit store for persistent storage.

logger ILogger<DefaultAuditLogger>

The logger for diagnostic output.

Methods

LogAsync(AuditEvent, CancellationToken)

Logs an audit event to the audit store.

public Task<AuditEventId> LogAsync(AuditEvent auditEvent, CancellationToken cancellationToken)

Parameters

auditEvent AuditEvent

The audit event to log.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<AuditEventId>

The event ID and hash assigned to the durably persisted event.

Remarks

This operation is fail-closed. If the underlying audit store cannot durably persist the event, the failure is surfaced as AuditPersistenceException rather than returning a success-shaped AuditEventId. A returned AuditEventId therefore always denotes a durably recorded event. Callers requiring fail-open behavior must catch AuditPersistenceException and apply their own retry or queueing policy.

Exceptions

AuditPersistenceException

Thrown when the audit store fails to durably persist the event.

VerifyIntegrityAsync(DateTimeOffset, DateTimeOffset, CancellationToken)

Verifies the integrity of the audit log for the specified time range.

public Task<AuditIntegrityResult> VerifyIntegrityAsync(DateTimeOffset startDate, DateTimeOffset endDate, CancellationToken cancellationToken)

Parameters

startDate DateTimeOffset

The start of the verification period.

endDate DateTimeOffset

The end of the verification period.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<AuditIntegrityResult>

The integrity verification result.

Remarks

This operation may be expensive for large time ranges. Consider running during maintenance windows for large-scale verification.