Adds an Audit Logs collection to Payload and records operations on the collections you select. Each entry stores the entity, document ID, operation, the acting user, and the original and new data as JSON. Configured through the plugins array, with options for access control, hiding the collection from navigation, and the user collection slug. Requires Payload 3.
Audit log plugin for Payload CMS
Installation
npm i payload-audit-logs6
Stars
0
Forks
0
Open Issues
4 months ago
Last Updated
0
Weekly Downloads
v1.2.0
npm Version
56.1 KB
Unpacked Size
0
Dependencies
Trends appear after 7 days of data. Daily snapshots have not started yet.
Trends appear after 7 days of data. Daily snapshots have not started yet.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1216292583-root)<a href="https://payloaddirectory.dev/plugins/1216292583-root"><img src="https://payloaddirectory.dev/badge/1216292583-root.svg" alt="Payload Directory"></a>README
A Payload CMS plugin to automatically track and log CRUD operations (Create, Read, Update, Delete) on specified collections.
create, read, update, and delete operations.originalData (before change) and newData (after change) for full auditability.pnpm add payload-audit-logs
# or
npm install payload-audit-logs
# or
yarn add payload-audit-logs
Add the plugin to your Payload configuration:
import { buildConfig } from 'payload'
import { auditLogPlugin } from 'payload-audit-logs'
export default buildConfig({
plugins: [
auditLogPlugin({
collections: {
posts: {
operations: ['create', 'update', 'delete'],
},
users: {
operations: ['create', 'update', 'delete'],
},
media: {
operations: ['create', 'update', 'delete'],
},
},
userCollection: 'users', // Optional, defaults to 'users'
}),
],
// ... rest of your config
})
The plugin accepts the following options:
| Option | Type | Default | Description |
|---|---|---|---|
collections | Record<string, { operations: string[] }> | {} | A map of collection slugs to track and the operations to log for each. |
disabled | boolean | false | If true, the plugin will be disabled. |
userCollection | string | 'users' | The slug of the collection used for users. |
auditLogsAccess | CollectionConfig['access'] | { ... } | Access control functions for the generated Audit Logs collection. |
hideAuditLogs | boolean | ((args: { user: PayloadRequest['user'] | null }) => boolean) | false | Hide the Audit Logs collection from the sidebar navigation. |
You can specify which operations to log for each collection:
create: Logs when a new document is created.read: Logs when a document is retrieved.update: Logs when an existing document is modified.delete: Logs when a document is removed.CAUTION: Enabling the
readoperation can significantly increase database storage consumption and create redundant logs, especially for high-traffic collections. Use it sparingly and only when strictly necessary for auditing sensitive information.
import { buildConfig } from 'payload'
import { auditLogPlugin } from 'payload-audit-logs'
export default buildConfig({
plugins: [
auditLogPlugin({
// Track specific collections
collections: {
posts: {
operations: ['create', 'update', 'delete'],
},
// Sensitive data might require 'read' logging
settings: {
operations: ['read', 'update'],
},
},
// Configure user collection if it's not 'users'
userCollection: 'admins',
// Useful for environment-specific disabling
disabled: process.env.NODE_ENV === 'test',
}),
],
})
When the plugin is enabled, it automatically adds an Audit Logs collection to your Payload admin panel.
create, read, update, or delete).update and delete).create, read, and update).By default:
You can fully customize these rules by providing the auditLogsAccess property in your plugin configuration.
If you want to contribute or modify the plugin:
pnpm install.pnpm dev.pnpm test.MIT
Tags
payload audit
Automatic audit logging of create, update, delete and auth events across all Payload collections
70712/wk4v3
activity log
Log activity on selected collections and globals in a dedicated activity log collection
660/wk114v3
authors info
Tracks who created, edited and published documents across collections and globals
6557/wk181v3
payload auditor
Audit logging for Payload collections and globals using hook operations, with buffered writes and automatic log cleanup
640/wk79v3
activity log
Chronological activity feed of document changes and user logins across all collections and globals
6129/wk15v3
payload hooks
Collection hook helper that logs Payload operations through the Nexload logger
550/wk2v?