Interface IAuditLogger
- Namespace
- Excalibur.Compliance
- Assembly
- Excalibur.Compliance.Abstractions.dll
Provides audit logging services for compliance and security monitoring.
public interface IAuditLogger
Remarks
The audit logger creates a hash-chained, tamper-evident audit trail: - Each event is hashed with the previous event's hash - Integrity can be verified for any time range - Events are immutable once logged
Implementation notes: - LogAsync is fail-closed: a store failure is surfaced as AuditPersistenceException, never masked behind a success-shaped result. Callers must not treat a returned AuditEventId as anything other than a durably persisted event. - Events must be persisted durably before returning a successful result. - High-frequency logging should use batching.
Methods
LogAsync(AuditEvent, CancellationToken)
Logs an audit event to the audit store.
Task<AuditEventId> LogAsync(AuditEvent auditEvent, CancellationToken cancellationToken)
Parameters
auditEventAuditEventThe audit event to log.
cancellationTokenCancellationTokenA 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.
Task<AuditIntegrityResult> VerifyIntegrityAsync(DateTimeOffset startDate, DateTimeOffset endDate, CancellationToken cancellationToken)
Parameters
startDateDateTimeOffsetThe start of the verification period.
endDateDateTimeOffsetThe end of the verification period.
cancellationTokenCancellationTokenA 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.