Adding audit logs: what enterprise buyers expect to see

What an audit log in a SaaS should record, how to store it so it cannot be edited, what to show customers, and how long to keep it. A build checklist.

The short answer

An enterprise-ready audit log records who did what, to which record, when, from where and with what result, for sign-ins, permission changes, data exports, deletions and settings. It is append-only, written in the same transaction as the change, scoped per tenant, searchable and exportable by the customer's admins, and kept for a period you state. Build it before the first security questionnaire asks.

On this page
  1. What events belong in an audit log?
  2. What does each entry contain?
  3. How do you make it trustworthy?
  4. What should customers be able to do with it?
  5. How long do you keep it?
  6. What are the common mistakes?
  7. How do you build it in small steps?
  8. Working with us

When a larger customer evaluates your SaaS, the security questionnaire has a section on logging. “Does the product keep an audit trail of user and administrator actions? Can customers see it? Can it be exported?” If the answer is “we have server logs”, the deal slows down.

An audit log is not the same as application logs. Application logs help your developers debug. An audit log helps your customer’s security and compliance people answer: who changed this, and when?

What events belong in an audit log?

Start with what a customer’s admin would ask after an incident or a complaint:

  • Authentication: sign-in, failed sign-in, sign-out, password change, multi-factor changes, SSO sign-in, API key created or revoked.
  • Access and permissions: a user invited, a role changed, a user removed, a permission granted.
  • Data changes on important records: created, updated, deleted, with the fields that changed.
  • Data leaving the system: exports, report downloads, bulk reads through the API, file downloads.
  • Settings: security settings, integrations, billing contacts, domains and SSO configuration.
  • Staff access to customer data: when your own team views a tenant’s data for support. Enterprise buyers care about this most, and it is the one vendors forget.

Do not log everything. Reading a list page is noise. Log what matters for accountability.

What does each entry contain?

A good entry answers six questions:

Field Example
Who (actor) User id and display name at the time, or “API key: Reporting tool”, or “system job”
What (action) A stable code such as booking.cancelled, not a free sentence
On what (target) Record type and id
When UTC timestamp from the database clock
Where from IP address and client (browser or API), under privacy rules
Result and details Success or failure, the old and new values of changed fields, a request id

Store the actor’s name at the time as text as well as the id, because users get renamed and deleted.

How do you make it trustworthy?

An audit log that can be edited is worth little. These choices make it credible:

  1. Write it in the same transaction as the change. If the change commits, the log entry does too; if it rolls back, so does the entry. A log written afterwards by a separate job will sooner or later miss an event.
  2. Append-only. The application’s database role can insert into the audit table but not update or delete. Corrections are new entries.
  3. One table or stream per concern, scoped by tenant. Every row carries the tenant id, and the same tenant isolation rules apply: proving tenant isolation in CI.
  4. Move through the state machine. For records with a status, log each status move from one place. When status changes only go through one table of allowed moves, the log is complete by construction: status columns as state machines. Our Forkly orders keep an event row for each move.
  5. Include system actors. Background jobs changing data should be logged as “system”, with the job name.
  6. Keep it in the database you already run, and, for long retention, archive older rows to object storage rather than keeping a second stateful service.

What should customers be able to do with it?

  • See it. An admin page with filters for person, action, record and date range.
  • Export it. CSV or JSON, and ideally an API endpoint so their security tool can pull it. See adding an API.
  • Get it in their tools. Larger buyers sometimes ask for a stream to their SIEM. Build that later, after the page and export work.
  • Trust it. A short documented statement of what is logged, how long it is kept, and that entries cannot be changed.

Only tenant admins should see the tenant’s log. Your own staff access to it should be logged as well.

How long do you keep it?

Pick a retention period, write it down and apply it. The right number depends on your customers’ regulators and contracts, so ask them. Be careful with personal data in the log: IP addresses and names are personal data under GDPR, so state a purpose and a limit, and make sure deletion requests are handled consistently (for example, replace a deleted user’s name with “Deleted user” while keeping the entry). What GDPR means for a SaaS.

What are the common mistakes?

  • Logging only in the web layer. Actions through the API, imports and background jobs bypass it. Log at the service layer where the change happens.
  • Free-text messages. You cannot filter them. Use action codes, and render text from them.
  • Secrets in the log. Never write passwords, tokens or full card numbers. Redact fields by name.
  • No index. An audit table grows fast. Index by tenant and time, and by tenant and target.
  • No test. A test should do an action and check the entry, and also check that another tenant cannot read it.

How do you build it in small steps?

  1. Pick ten events: sign-in, role change, invite, delete, export, API key, SSO setting, status change on your main record, staff view, settings change.
  2. Add one function that writes an entry in the current transaction, and call it from those places.
  3. Add the admin page and an export.
  4. Write the one-page description for buyers.
  5. Add more events when customers ask.

Working with us

We build multi-tenant SaaS platforms with audit trails, role-based permissions and tenant isolation designed in, and we can add an audit log to an existing product. Describe your product and what your buyers have asked for through the contact page, or see our SaaS platform work.

Keep reading

Tell us what you want to build.

A product, a website, a search problem or a system that should work better. We reply with a plain answer and the first step.

A few sentences are enough (at least 20 characters).

We use your details only to answer your inquiry. See our privacy policy.