---
title: Audit logs
project: Total.js V5
version: 0.0.20
section: guides
language: en
license: MIT
url: https://totaljs.es/docs/total-js-v5/0-0-20/guides/audit-logs/
updated: 2026-11-16T15:32:32.495Z
---

# Audit logs

> Record who did what with AUDIT() and $.audit(), audit actions after they succeed, and store the records where you need them.

`AUDIT()` writes who did what. It reads the user, IP address, user agent, URL and action from `$`:

```js
NEWACTION({
	id: 'Orders/remove',
	params: '*id:UID',
	action: function($) {
		$.audit('Removed order {params.id} by {user.name}');
		$.success();
	}
});
```

A record contains `userid`, `createdby` (the `name`, `nick` or `alias` of the user), `sessionid`, `ip`, `ua`, `url`, `action`, `type`, `message`, `app` and `dtcreated`. `data` contains the params, query, model and uploaded files (`name`, `filename`, `size`, `width`, `height`) as JSON, without the fields `password`, `token`, `accesstoken`, `access_token` and `pin`.

Each record is a line of JSON in `/logs/audit.log` (or `/logs/<name>.log` for `AUDIT('name', $, ...)`). Replace `DEF.onAudit` to store records elsewhere. An action with `audit: true` or with a Tangular template (`audit: 'Removed {{ $.params.id }}'`) is audited into `/logs/actions.log` after it succeeds.
