Audit Trails in Business Software: What to Log and Why
An audit trail is a tamper-resistant record of who changed what, when, from where, and what the value was before and after. Log events that affect money, stock, permissions, approvals, deletions and exports. Keep passwords and full card data out of it, decide who may read it and for how long it is kept, and write all of this into your spec before the build starts.
What does an audit trail actually record?
Every entry should answer five questions about a single event. If one answer is missing, the entry is much less useful when you need it.
- Who: the signed-in user, or the named system process that acted on their behalf.
- What: the type of action and the record it touched, such as an invoice, a product or a user role.
- When: the date and time the change was saved, recorded by the system and not typed by the user.
- From where: the device, network address or channel the request came from, such as the web app, a mobile app or an integration.
- Old and new value: what the field held before and what it holds now.
The old and new value is the part owners most often forget to ask for. Without it you can see that a price changed, but not what it changed from.
An audit trail is not the same as a technical error log. Error logs help developers fix faults. An audit trail helps the business answer questions about its own records. They have different readers, different contents and different retention needs. For the technical side, see software monitoring after launch.
Which events should your software log?
Start with the actions where a wrong or unexplained change would cost you money, stock, trust or control. The table below is a starting point for your spec. Adjust it to your business.
| Event | Fields captured | Who reviews |
|---|---|---|
| Price, discount or credit note changed | User, time, source, record, old and new amount, reason if entered | Owner or finance lead |
| Payment recorded, refunded or reversed | User, time, source, order or invoice reference, amount, method type | Finance lead |
| Stock adjusted or transferred | User, time, location, item, old and new quantity, reason | Operations or stores manager |
| User created, role changed or access removed | Acting user, time, affected user, old and new role | Owner or system administrator |
| Approval given, rejected or overridden | Approver, time, item approved, decision, comment | Process owner |
| Record deleted or restored | User, time, record type and reference, a snapshot of what was removed | Owner or manager |
| Data exported or report downloaded | User, time, source, what was exported, filters used | Owner or administrator |
| Sign-in failures and sign-in from a new device | Account, time, source, outcome | System administrator |
Two events deserve extra care. Permission changes let someone give themselves power, so they should always be logged. Exports move a copy of your data outside the system, where no later log can follow it. For how roles and access fit together, read authentication vs authorization in software permissions.
What should you not log?
An audit trail that stores secrets becomes a new risk. Write the exclusions into the spec as clearly as the inclusions.
- Passwords and security answers. Log that a password was changed, never the password itself, old or new.
- Full card data. If a payment reference is needed, keep only a reference issued by the payment provider, plus at most a masked ending.
- Access tokens and keys. Record that an integration acted, not the credential it used.
- Unneeded personal detail. If a change to a customer record is logged, record which field changed. Where the value is sensitive, consider storing a masked version.
Ask your build partner how sensitive fields are handled in old and new values. This is the point where good intentions most often leak data into the log.
Who should be able to read the log?
Fewer people than you might expect. A log that anyone can read or edit is not much of a control.
Set these rules in the spec:
- Read access is a separate permission. Not every manager needs it, and the people whose actions are being recorded should not decide who sees it.
- No one edits or deletes entries through the normal application, including administrators. Corrections are added as new entries.
- Access to the log is itself logged. Viewing or exporting the trail is an event like any other.
- Someone reviews it on a schedule. A log nobody reads only helps after a problem. Name the reviewer for each event type, as in the table above.
How long should you keep the log?
Keep entries as long as the business has a reason to ask about them, and no longer. Longer retention helps with disputes and investigations. It also keeps personal data around, and it adds storage and management cost.
For your spec, agree three things:
- How long entries stay immediately searchable in the application.
- Whether older entries move to cheaper storage that is slower to search.
- What happens at the end of the period, and who approves it.
The required period depends on your country, sector and contracts. Ask your accountant or legal adviser for it rather than copying a number from another business. Align the audit log with the rest of your data rules in your software data retention and deletion policy.
Why is adding an audit trail late so costly?
An audit trail cannot recreate history. If the system never recorded the old value, nothing can supply it afterwards. Every change made before the feature existed stays unexplained.
There is a cost in the build too. Capturing changes reliably usually touches every screen, import, integration and background job that writes data. Adding it afterwards means finding each of those paths, and any one that is missed becomes a blind spot. Doing it at the start means it is a shared rule that each new feature follows.
This is also why it belongs in your requirements document. If you are writing one, see how to write a software requirements document.
A worked example
This example is illustrative. A distributor lets a stores manager adjust stock quantities. Months later, the count for one item is wrong.
With an audit trail, the owner opens the item's history and sees a sequence of entries: the user, the time, the warehouse location, the old quantity, the new quantity and the reason entered. The owner can see that one adjustment was made from a device not normally used and that no reason was entered. That is a specific question to ask, with evidence.
Without an audit trail, the owner sees only the current quantity and has to rely on memory.
What common mistakes should you avoid?
Logging only the final value. Without the old value, you cannot tell what changed or reverse it with confidence.
Letting users type their own timestamps. Time should come from the system.
Treating a soft delete as a log. Hiding a record is not the same as recording who hid it and when.
Forgetting system actions. Imports, scheduled jobs and integrations change data too. Record which process acted.
Storing secrets in the log. Decide exclusions before the build, not after a review.
Writing the log and never reading it. Assign reviewers and a review rhythm.
When does this not apply?
Not every product needs a full trail. A simple internal tool with one user and no financial or personal data may only need a basic created-and-updated stamp. A public marketing site with no accounts has little to audit.
As soon as more than one person edits records that carry money, stock or customer information, a proper trail is worth specifying.
FAQ
Is an audit trail the same as a backup?
No. A backup stores a copy of your data so you can restore it. An audit trail records the history of changes, including who made them and what changed. A backup shows what existed at one point, while the trail explains how it got there.
Should every field change be logged?
Not necessarily. Log fields that affect money, stock, access, approvals and customer records. Cosmetic changes, such as a screen layout preference, rarely need an entry. Agree the list in your spec, because logging everything adds noise, storage cost and more sensitive data to protect.
Can administrators edit the audit log?
They should not. If administrators can alter entries, the log cannot be trusted as evidence. Corrections should be added as new entries that refer to the original, and any access to the log by administrators should itself be recorded and reviewed.
Will an audit trail slow down the software?
It adds a small amount of work to each saved change, and the effect is usually small when it is designed in from the start. Ask your build partner how entries are written and searched, and test with realistic volumes before launch.
*Need an audit trail specified properly before you build? Start a conversation →*