Gabriel Cucos

SaaS Audit Logs Done Right: Track Who Changed What Without Slowing Your App

TL;DR · 30-Second Summary
Founders, Product Leads & Builders7 min

Enterprise buyers and compliance teams always ask 'who changed that permission or exported that list?' An append-only audit log answers this cleanly without slowing down everyday user actions.

Append-only SaaS audit log table recording actor, action, resource, and timestamp

What an Audit Log Is (And Why Business Buyers Ask for It)

Whenever a teammate deletes a project, changes billing permissions, or exports customer data in a B2B app, you need a reliable record answering four simple questions: who did it, what changed, which record it affected, and when.

Without an audit trail, debugging customer disputes or passing security questionnaires turns into guesswork across server logs. Done right, audit logging runs quietly in the background without blocking normal app clicks.

| Approach | Tamper Resistance | Speed Impact on App | Useful For Support & Security? | | :--- | :--- | :--- | :--- | | Plain Application Console Logs | Low (rotates / unstructured) | Low | Hard to search by customer | | Updating an updated_by Column | Poor (overwrites history) | None | Shows only the last edit | | Append-Only Audit Table / Queue | High (insert-only rows) | Negligible | Clear history + easy export |

Why Naive Audit Logging Slows Down Growing SaaS Apps

Most audit logging trouble happens for two practical reasons:

  • Writing Synchronously Inside Heavy Loops: Calling an external logging service before returning a UI response stalls user actions whenever the logger is slow.
  • No Filtering or Archiving Policy: Logging every trivial read view fills database storage quickly, making genuine security events (role.updated, api_key.created, data.exported) harder to find.

Clean Append-Only Audit Table in Postgres / Supabase

Keep your schema focused on real accountability events, prevent accidental edits/deletes via RLS policies, and index (tenant_id, created_at DESC) so customer activity feeds stay sub-10ms:

SQL
-- Immutable audit trail scoped by workspace/tenant
CREATE TABLE IF NOT EXISTS public.audit_events (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  tenant_id text NOT NULL,
  actor_id text NOT NULL,
  action text NOT NULL,
  resource_type text NOT NULL,
  resource_id text NOT NULL,
  metadata jsonb NOT NULL DEFAULT '{}'::jsonb,
  created_at timestamptz NOT NULL DEFAULT now()
);

CREATE INDEX IF NOT EXISTS idx_audit_events_tenant_time
  ON public.audit_events (tenant_id, created_at DESC);

ALTER TABLE public.audit_events ENABLE ROW LEVEL SECURITY;

-- Workspace admins can only READ their own events; never UPDATE or DELETE
CREATE POLICY "Admins read own audit logs"
  ON public.audit_events FOR SELECT
  TO authenticated
  USING (tenant_id = (auth.jwt() ->> 'tenant_id'));

Looking to audit how your site handles security headers or server-side event pipelines as well? Try our free Tracking & Security Headers Inspector or explore our gabrielcucos.dev Architecture Case Study.

Practical Implementation Checklist

  • Track meaningful state changes first: Login policy updates, role changes, billing updates, webhook edits, and CSV exports.
  • Keep logs append-only: Grant INSERT and SELECT only—never allow UPDATE or DELETE on historical audit events.
  • Set a clear retention window: Archive rows older than 12–24 months to cold storage instead of paying SSD prices forever.

Need cleaner security logging, Postgres RLS rules, or automated compliance checks? Request a Free 48h Diagnosis.

Practical Next Step

Want this working inside your business?

Whether you're a founder fixing tracking leaks or a team scaling SEO and AI workflows, share your site and bottleneck for a clear diagnostic within 48 hours.

HOW THIS GUIDE IS STRUCTURED

Built in layers: plain-English summary at the top for founders and marketing leads, followed by concrete examples, comparison tables, and technical code below for builders.