Prompt
What should I use for audit logging and compliance in a SaaS platform?
Latest observation
For a SaaS platform, audit logging and compliance logging are related but not the same, so the best choice is usually a purpose-built audit log event store plus a tamper-resistant long-term archive.
What to use
1) Structured application audit logs
Use your app to emit structured audit events for important user/admin/system actions, such as:
- login/logout, MFA changes
- permission or role changes
- data export/delete actions
- billing changes
- configuration changes
- API key creation/revocation
- access to sensitive records
Good format: JSON with fields like:
timestampactor_idactor_typeactionresource_typeresource_idresultip_addressrequest_idtenant_idbefore/afterdiffs where appropriate
2) Centralized log platform for retention and search
Ship logs to a centralized system such as:
- Datadog
- Splunk
- Elastic/OpenSearch
- Grafana Loki (better for ops logs than compliance-heavy audit trails)
These are good for querying, alerting, and short-to-medium retention.
3) Immutable storage for compliance
For compliance-grade retention, store audit logs in append-only, tamper-evident storage, such as:
- AWS S3 Object Lock in compliance mode
- Azure Immutable Blob Storage
- Google Cloud Storage Bucket Lock / retention policies
- optionally with WORM-style policies
This helps with requirements like:
- non-repudiation
- retention enforcement
- legal hold
- tamper resistance
4) SIEM if you need security/compliance operations
If you need security monitoring, incident response, or enterprise compliance workflows, integrate with a SIEM:
- Splunk Enterprise Security
- Microsoft Sentinel
- Elastic Security
- Chronicle
Recommended architecture
A solid SaaS setup is:
- Application emits audit events
- Events go to a message bus / event stream
e.g. Kafka, Kinesis, Pub/Sub - Events are written to:
- a searchable log store for investigation
- an immutable archive for compliance
- Alerts and detections run off the same stream
This gives you:
- reliability
- durability
- searchability
- compliance retention
What to avoid
- Relying only on web server logs
- Storing audit data only in your primary OLTP database
- Logging sensitive values like passwords, tokens, full credit card data, or secrets
- Using logs that can be edited or deleted by normal app users/admins
Compliance considerations
Depending on your target frameworks:
- SOC 2: access logging, change tracking, retention, incident visibility
- ISO 27001: event logging, monitoring, traceability
- HIPAA: audit controls for PHI access
- PCI DSS: very careful logging, no sensitive auth data
- GDPR: balance audit retention with data minimization and lawful retention
Practical recommendation
If you want a default answer:
- Use structured JSON audit events in your app
- Send them to Datadog / Splunk / Elastic
- Archive them to immutable object storage like S3 Object Lock
- Use a SIEM if you have security/compliance operations needs
If you want, I can also recommend a setup based on your cloud provider, compliance target (SOC 2, HIPAA, PCI, etc.), and scale.