A tamper-resistant record of who did what and when, for security, compliance and investigations.
An audit log is a record of who did what, to which thing, and when, kept so that people can check the facts later. It is for security, compliance and investigations, not for debugging code.
An application log helps a developer fix a bug: stack traces, debug messages, timings. An audit log helps an auditor, a security team or a lawyer answer questions like "who gave Bob admin rights?" or "who exported the payroll file last Tuesday?". The audience is different, so the rules are different.
| Application log | Audit log | |
|---|---|---|
| Purpose | Debug and operate the system | Prove who did what |
| Reader | Developers and on-call engineers | Security, compliance, auditors, legal |
| Content | Free text, errors, timings | Structured: actor, action, resource, result |
| Completeness | Sampling and dropping is fine | Must not lose events |
| Retention | Days or weeks | Months or years, by policy |
| Tampering | Not a concern | Must be prevented or detected |
| Record these | Never put these in the log |
|---|---|
| Logins, logouts, failed logins, MFA changes | Passwords, even wrong ones |
| Permission and role changes | API keys, session tokens, private keys |
| Access to sensitive records (who read what) | Full card numbers or full personal records |
| Admin actions, impersonation, config changes | Whole request bodies by default |
| Data exports and deletions | Anything you could not show to an auditor |
| Changes to the audit settings themselves | Free-text that may contain personal data |
Log the fact and an id ("password changed for user 42"), not the secret. For a data change you can keep the old and new values of a non-sensitive field, or a pointer to a version.
| # | Time | Who | Action | Resource | Result | Chain hash | Actions |
|---|---|---|---|---|---|---|---|
| 1 | 09:01 | alice | login | console | ok | 224519 | |
| 2 | 09:03 | alice | grant admin | user bob | ok | a7f42f | |
| 3 | 09:12 | bob | read | payroll.csv | ok | e0e318 | |
| 4 | 09:15 | bob | export | payroll.csv | ok | a2288c | |
| 5 | 09:20 | carol | login | console | denied | 299cec | |
| 6 | 09:41 | bob | delete | audit-config | denied | aa5010 | |
| 7 | 10:02 | alice | revoke admin | user bob | ok | ec0246 | |
| 8 | 10:30 | dave | read | customers | ok | 667c14 |
Each chain hash is hash(previous hash + this entry). Here a small teaching hash (FNV-1a, 6 hex characters) stands in so the page needs no libraries. A real audit log uses a cryptographic hash such as SHA-256, plus write-once storage and an off-site copy, because an attacker who can rewrite the whole log can also recompute the whole chain.
{
"time": "2026-12-04T09:03:11Z",
"actor": { "id": "u_42", "type": "user" },
"action": "role.grant",
"resource": { "type": "user", "id": "u_77" },
"details": { "role": "admin" },
"result": "success",
"source_ip": "203.0.113.9",
"request_id": "req_8f2c",
"prev_hash": "a41c09..."
}| Term | Meaning in easy words |
|---|---|
| Audit log | A tamper-resistant record of who did what, to what, and when |
| Actor | The user, service or admin who performed the action |
| Append-only | New entries can be added, but old ones cannot be changed or removed |
| WORM | Write once, read many: storage that refuses edits after writing |
| Hash chain | Each entry includes the hash of the previous one, so edits break the chain |
| Tamper-evident | A change cannot be prevented, but it can be detected |
| Non-repudiation | The actor cannot credibly deny having done the action |
| Retention | How long the log must be kept |
| Legal hold | An order to keep certain records even beyond normal retention |
| Separation of duties | The people who run a system cannot edit its audit trail |
| Request ID | A value that ties an audit entry to the logs and traces of the same request |
| SIEM | A security tool that collects logs and raises alerts |
| Choice | We gain | We lose |
|---|---|---|
| Log every read | Full visibility of data access | Huge volume and cost |
| Log only writes and admin actions | Smaller and simpler | No record of who looked |
| Synchronous write | No lost entries | Slower requests |
| Async via queue or outbox | Fast requests | More parts to run, brief delay |
| Hash chain only | Cheap tamper detection | An attacker with full write access can rebuild it |
| WORM plus off-site copy | Strong protection | Cost and harder to correct mistakes |