Class AuditFileSink
AuditEntry records.
The in-memory AuditStore ring buffer is deliberately volatile — it is
bounded and is wiped by the very reset it records. This sink is a
separate optional writer that observes the same entries as they are
recorded and appends one JSON object per line ("newline-delimited JSON") to a
file, giving a tamper-evident, restart-surviving audit trail. It never reads
from or mutates the ring buffer — the ring stays exactly as-is, honouring the
AuditEntry contract that the in-memory store must never "become a sink".
Configured by the mockserver.auditLogFile property (empty default = off,
behaviour unchanged). The path is resolved once, on the first entry written
(fixed thereafter, mirroring AuditStore's fixed-at-first-read capacity).
All write and open failures are handled by logging a single WARN and disabling
the sink — an IO error here must never crash request handling. Rotation is out
of scope: the file grows append-only; use external log rotation (e.g. logrotate)
or a bounded controlPlaneAuditMaxEntries + periodic archival if needed.
-
Method Summary
Modifier and TypeMethodDescriptionstatic AuditFileSinkvoidwrite(AuditEntry entry, String configuredPath) Appendsentryas a single NDJSON line to the configured audit log file, flushing per line.
-
Method Details
-
getInstance
-
write
Appendsentryas a single NDJSON line to the configured audit log file, flushing per line. A no-op whenconfiguredPathis blank, or once the sink has been disabled by an earlier IO error. Never throws.- Parameters:
entry- the audit entry to persist (also held in the in-memory store)configuredPath- the target file path; resolved once on first call and fixed thereafter
-