Your SaaS Has Logins. It Doesn't Prove Who Did What.

TarunSoftware Development 6 min read 14 Nov 2026

Quick answer: A login proves who got in, not what they did. Add an append-only audit_events table, written in the same database transaction as every sensitive change, recording actor, action, target, time, result, source, and before/after values. Start with a short list of events customers will actually ask about, keep the table read-only for the app, and check the CERT-In 180-day and DPDP one-year log rules below.

Definitions, so nothing gets mixed up:

  • Authentication log — records sign-ins: who authenticated, when, from where. It stops at the door.
  • Application audit log — records business actions after login: who changed which record, what the old and new values were, and whether it worked.
  • Debug log — for engineers: errors, stack traces, performance. Useful for fixing bugs, not for answering a customer or an auditor.

This article is about the middle one.

Why login logs are not an audit trail

Authentication tells you someone logged in. It does not give you a record of what happened after that. The question that breaks a login-only product is simple, and it usually arrives from a customer, an auditor, or your own support team: "Who deleted this invoice?" "Who changed this user's role?" "Who exported this report last Tuesday?"

If your product has sign-in and roles but no record of actions after sign-in, you cannot answer. Your identity layer won't save you either. Identity tools such as Keycloak record user and admin events (who logged in, who changed identity configuration), but they don't capture every operation inside your application. You need both layers: identity events from the identity provider, and your own audit log for SaaS business actions inside the app.

For a longer take on the identity-provider side, see this dev.to post.

What to record: the fields of an audit event

The SaaS audit log fields that matter, per event:

Field Example Why
Actor user_4821 (admin) Who did it; resolve IDs to names when you display them
Actor type user, admin, service Separates humans from background jobs
Action role.changed What happened, in a stable, searchable format
Target invoice INV-1042 Which record was touched
Timestamp 2026-11-14T09:31:07+05:30 When; store time in an international format with the offset
Result success / failure Failed attempts are often the interesting ones
Source details IP, user agent Where the action came from
Request ID req_9f31… Lets you tie the audit row to your other logs
Before / after {"role":"viewer"} → {"role":"admin"} For sensitive changes, the old and new values are the answer to "who changed what and when"

This follows the when / where / who / what model in the OWASP Logging Cheat Sheet — a good reference to keep open while you design this.

What never to record

The same OWASP guidance is blunt about what stays out of logs:

  • Passwords
  • Access tokens
  • Encryption keys
  • Raw session IDs — hash them if you genuinely need the reference

If a value would let someone impersonate a user or decrypt data, it does not belong in an audit row.

Which events to log first

Don't put a trigger on every table. Start with the actions a customer, auditor, or support team will actually ask about. Items 1–5 come from OWASP's must-log events; items 6–8 are the SaaS actions most audit-log build guides add:

  1. Sign-in successes and failures. Your identity provider may already hold these; make sure you can get at them.
  2. Authorization failures — someone tried to reach something they shouldn't.
  3. Permission and role changes. The classic "who changed what and when" question.
  4. User administration — adding and removing users.
  5. All administrator and support actions, including support staff acting as a user.
  6. Data exports and deletions. Both directions of bulk data movement.
  7. Billing and plan changes.
  8. API key and security setting changes.

How to build it: schema, write path, screen

The schema

One table, append-only:

CREATE TABLE audit_events (
  id          bigserial PRIMARY KEY,
  occurred_at timestamptz NOT NULL DEFAULT now(),
  actor_id    text NOT NULL,
  actor_type  text NOT NULL CHECK (actor_type IN ('user', 'admin', 'service')),
  tenant_id   text NOT NULL,
  action      text NOT NULL,
  target_type text,
  target_id   text,
  result      text NOT NULL CHECK (result IN ('success', 'failure')),
  ip          inet,
  user_agent  text,
  request_id  text,
  before      jsonb,
  after       jsonb
);

The write path

Write the audit row in the same database transaction as the change itself, so both commit or both roll back:

begin transaction
  apply the change (update role, delete record, ...)
  insert audit_events row (actor, action, target, before, after, ...)
commit            -- on error, roll both back

Do this at the service or domain layer, not only at the API gateway. Logging that only happens on HTTP requests misses background jobs, cron, and admin scripts — exactly the places where "how did this change?" gets hard to answer.

Protect the table

  • Make it append-only: the application role can INSERT but not UPDATE or DELETE.
  • Restrict who can read it.
  • Build tamper detection, and copy rows to read-only storage soon after they're written.
  • Record and monitor access to the logs themselves. "Who looked at the audit log" is also an audit event.

The screen

Give customer admins a filterable audit log screen — filter by user, by action, by date range. That turns the audit trail from a cost centre into a feature your customers can use themselves. If you're scoping this as part of a larger product build, Gigzman also works on SaaS and startup builds.

Retention and Indian rules

Two Indian requirements shape how long you keep logs. This is not legal advice; check with your lawyer.

CERT-In log retention: 180 days. The CERT-In directions of April 2022 (dated 28 April 2022) require all service providers, intermediaries, data centres, body corporate and Government organisations to enable logs of all ICT systems and maintain them securely for a rolling period of 180 days within Indian jurisdiction, to be provided to CERT-In along with incident reports or when directed. CERT-In's FAQs add detail on storage location — read them alongside the directions.

DPDP Rules: logs for one year. The DPDP Rules, 2025, notified in November 2025, list reasonable security safeguards in Rule 6, including access control and "visibility on the accessing of such personal data, through appropriate logs, monitoring and review" — and retaining such logs and personal data for one year, unless another law requires otherwise. These obligations are phased in, so check when they apply to you.

Plan storage with both in mind: keep recent rows in the live table for fast filtering, and move older rows to read-only storage rather than deleting them.

Mistakes to avoid

  • Logging only at the API gateway. You lose background jobs, cron, and admin scripts.
  • Storing secrets in audit rows. No passwords, tokens, keys, or raw session IDs.
  • Editable rows. If an admin can update or delete audit events, the log proves nothing.
  • Logging an admin user ID with no name resolution. usr_4821 means nothing to a customer; resolve it to a name at read time.
  • No timezone on timestamps. Store time in an international format with the offset.
  • No request ID. Without it, you can't connect the audit row to the rest of your logs for the same action.

Building it in, or bolting it on

An audit log is cheaper to design in than to add later. On Gigzman's custom software development page, permissions and audit trail are listed as part of what a build includes — in the page's words, "Who can see what, who changed what, and when," and, on doing it late: "Retrofitting this into a live system is painful and expensive." An engagement starts from ₹2,00,000, typically runs 8–16 weeks, and covers admin tooling alongside permissions and audit trail. It's not for you if off-the-shelf covers most of what you need.

Disclosure: Gigzman builds custom software, so weigh this accordingly.

I'm Tarun, founder of Gigzman.

Questions people ask

Is an authentication log the same as an audit log?

No. An authentication log records sign-ins. An application audit log records what users, admins and services did after sign-in: the action, the record touched, the result and the old and new values.

What should a SaaS audit log never contain?

Passwords, access tokens, encryption keys and raw session IDs. The OWASP Logging Cheat Sheet lists these as data to exclude; hash a session ID if you need to reference it.

How long should an Indian SaaS company keep logs?

The CERT-In directions of April 2022 ask covered entities to keep ICT system logs for a rolling 180 days in India, and DPDP Rule 6 asks Data Fiduciaries to keep access logs and personal data for one year unless another law says otherwise. Check with your lawyer which applies to you.

Should I log every table with a database trigger?

Start smaller. Log the actions a customer, auditor or support team will ask about (role changes, user management, admin actions, exports, deletions, billing and security settings) and write each audit row in the same transaction as the change.

Want this done on your site?

Tell us what you are working with and we will come back with a plan.

Start a Project
Get Started

Ready to Build Something That Moves Your Business Forward?

Share your ideas and we’ll come back with a clear plan, a timeline and a price.

30-Minute Discovery

A focused conversation to understand your goals, challenges and opportunities.

Direct Team Conversation

Speak directly with our strategists and developers, no middle layers.

No-Commitment First Call

Get clear insights and practical recommendations with zero obligation.

Start a project

Five fields. We reply with a plan, a timeline and a price.

Prefer the long form? Open the contact page. By sending this you agree to our Privacy Policy.