Video in progress
Why is sending application logs, audit logs and analytics events through one log pipeline a bad idea?
Their requirements differ: application logs can be sampled, lost and deleted after 14 days, while an audit log must not be lost or altered and must be kept for years, and analytics events have a schema and are for business analysis. In a single pipeline, either the audit becomes unreliable or the debug logs become needlessly expensive.
📖 Answer
Comparing the three types by requirements:
| Application log | Audit log | Analytics event | |
|---|---|---|---|
| Purpose | debugging | who did what and when, legal evidence | business metrics, funnels |
| Loss | acceptable (sampling, drop) | not acceptable | slightly acceptable |
| Schema | free-form | strict | strict, versioned |
| Retention | days to weeks | years (regulator requirement) | months to years |
| Modification | irrelevant | forbidden (append-only) | can be reprocessed |
| Reader | engineers | auditors, security | analysts |
What breaks in one pipeline. When the async appender queue fills up, logs are dropped, and audit records too. If sampling is turned on to save cost, the analytics numbers break. If retention is cut to 14 days, the record the auditor asks for is gone. Access to debug logs is given broadly, while the audit log contains sensitive data.
The separation I make:
- Audit is written inside the business transaction (for example via a transactional outbox), so you never get "the action happened but the audit wasn't written". Storage is append-only, WORM or an immutable bucket, with separate access rights.
- Analytics is schema'd events (Avro or Protobuf, schema registry), going through Kafka to the data platform. The product team owns it.
- Application logs go through the ordinary observability pipeline, with sampling and short retention.
This should show in the code too: log.info("User {} changed limit", ...) is not an audit. For audit, use a separate AuditService.record(...) interface, so the developer knows exactly which channel they are writing to. In practice this separation is most often made after a regulator inspection, and doing it in advance is much cheaper.
Sign up to mark studied questions and save your progress.