Prompt
What should I use for audit logging in a SaaS app?
Latest observation
Oct 23, 2026
OpenAI APIWeb search: off
For a SaaS app, use a real audit log system that is:
- Append-only: never edit or delete past events
- Structured: store events as records, not plain text
- Queryable: searchable by user, action, resource, time, tenant
- Tamper-evident: hard to alter without detection
- Separate from app logs: audit logs are for compliance/security, not debugging
Good choices
1) Database-backed audit log table
Best for many SaaS apps to start.
Use a dedicated table like:
audit_eventsidtenant_idactor_user_idactionresource_typeresource_idbefore_stateafter_statemetadataip_addressuser_agentcreated_at
Why:
- simple
- easy to query
- easy to integrate
- good enough for many compliance needs
Tip: make it append-only with permissions preventing updates/deletes.
2) Centralized log platform
Use something like:
- Datadog
- Splunk
- Elastic/OpenSearch
- Grafana Loki
Good for:
- operational logs
- searching and alerting
- retaining large volumes
But:
- these are not always ideal as the sole system of record for compliance-grade audit trails unless configured carefully
3) Dedicated audit/event pipeline
If you need stronger guarantees or scale:
- write audit events to your DB
- also stream them to Kafka/Kinesis/Pub/Sub
- archive to object storage like S3/GCS with immutability controls
This gives:
- fast app queries
- durable archival
- better tamper resistance
Best practice recommendation
For most SaaS products:
- Store audit events in your primary DB in a dedicated append-only table
- Mirror them to immutable object storage for long-term retention
- Send them to your observability tool for search/alerting
- Use tenant-aware access controls so customers only see their own logs
What to log
Record:
- who did it
- what they did
- when it happened
- which tenant/account it affected
- object before/after state
- source IP / device info
- request ID / correlation ID
- success/failure outcome
Examples:
- user invited another user
- role changed
- password reset initiated
- billing plan changed
- API key created/revoked
- data exported/deleted
- admin impersonation
What not to use
Avoid relying only on:
- plain application logs
- browser console logs
- error tracking tools alone
- mutable database tables without access controls
Quick rule of thumb
- Small/medium SaaS: Postgres/MySQL audit table + object storage archive
- Larger/regulated SaaS: audit event stream + immutable archive + SIEM/log platform
If you want, I can recommend a specific stack for your situation (e.g. Postgres + AWS, or GCP, or a compliance-heavy B2B SaaS).