Mhmod-Hsn

payload audit logs

by Mhmod-Hsn
Logging & monitoring
v3
^3.82.1
MIT

Overview

Summary generated from the README

Adds an Audit Logs collection to Payload and records operations on the collections you choose. Each entry stores the entity, document ID, operation, acting user, and the original and new data as JSON. Access to the logs and their visibility in the sidebar are configurable. Requires Payload 3.82.1 or newer.

Features

  • Logs create, read, update and delete per collection
  • Stores original and new data as JSON for each change
  • Links each log entry to the user who performed it
  • Configurable access control for the Audit Logs collection
  • Option to hide the Audit Logs collection from the sidebar
  • Can be disabled per environment

Use cases

  • Track who changed or deleted content in an editorial team
  • Record reads of sensitive documents such as settings for compliance
  • Review before and after data when investigating unexpected changes

From the author

Audit log plugin for Payload CMS

Installation

npm i payload-audit-logs

6

Stars

0

Forks

0

Open Issues

6 months ago

Last Updated

66

Weekly Downloads

v1.2.0

npm Version

56.1 KB

Unpacked Size

0

Dependencies

GitHub stars

6+2 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 20266
Dec 4, 20266
Dec 3, 20266
Dec 2, 20266
Dec 1, 20266
Nov 30, 20266
Nov 29, 20266
Nov 28, 20266
Nov 27, 20266
Nov 26, 20266
Nov 25, 20266
Nov 24, 20266
Nov 23, 20266
Nov 22, 20266
Nov 21, 20266
Nov 20, 20266
Nov 19, 20266
Nov 18, 20266
Nov 17, 20266
Nov 16, 20266
Nov 15, 20266
Nov 14, 20266
Nov 13, 20266
Nov 12, 20266
Nov 11, 20266
Nov 10, 20266
Nov 9, 20266
Nov 8, 20266
Nov 7, 20266
Nov 6, 20266
Nov 5, 20266
Nov 4, 20266
Nov 3, 20266
Nov 2, 20266
Nov 1, 20266
Oct 31, 20266
Oct 30, 20266
Oct 29, 20266
Oct 28, 20266
Oct 27, 20266
Oct 26, 20266
Oct 25, 20266
Oct 24, 20266
Oct 23, 20266
Oct 22, 20266
Oct 21, 20266
Oct 20, 20266
Oct 19, 20266
Oct 18, 20266
Oct 17, 20266
Oct 16, 20266
Oct 15, 20265
Oct 14, 20265
Oct 13, 20265
Oct 12, 20264
Oct 11, 20264
Oct 10, 20264
Oct 9, 20264
Oct 8, 20264
Oct 7, 20264
Oct 6, 20264
Oct 5, 20264
Oct 4, 20264
Oct 3, 20264
Oct 2, 20264
Oct 1, 20264
Sep 30, 20264
Sep 29, 20264
Sep 28, 20264
Sep 27, 20264
Sep 26, 20264
Sep 25, 20264
Sep 24, 20264
Sep 23, 20264
Sep 22, 20264
Sep 21, 20264
Sep 20, 20264
Sep 19, 20264
Sep 18, 20264
Sep 17, 20264
Sep 16, 20264
Sep 15, 20264
Sep 14, 20264
Sep 13, 20264
Sep 12, 20264
Sep 11, 20264
Sep 10, 20264
Sep 9, 20264
Sep 8, 20264
Sep 7, 20264
Sep 6, 20264
npm weekly downloads

50+24 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 202650
Dec 4, 202648
Dec 3, 202646
Dec 2, 202642
Dec 1, 202638
Nov 30, 202631
Nov 29, 202628
Nov 28, 202624
Nov 27, 202624
Nov 26, 202624
Nov 25, 202628
Nov 24, 202621
Nov 23, 202622
Nov 22, 202624
Nov 21, 202623
Nov 20, 202623
Nov 19, 202627
Nov 18, 202634
Nov 17, 202634
Nov 16, 202634
Nov 15, 202638
Nov 14, 202646
Nov 13, 202645
Nov 12, 202654
Nov 11, 202643
Nov 10, 202644
Nov 9, 202643
Nov 8, 202640
Nov 7, 202632
Nov 6, 202636
Nov 5, 202622
Nov 4, 202623
Nov 3, 202626
Nov 2, 202629
Nov 1, 202628
Oct 31, 202625
Oct 30, 202620
Oct 29, 202619
Oct 28, 202615
Oct 27, 202614
Oct 26, 202612
Oct 25, 20268
Oct 24, 20269
Oct 23, 20267
Oct 22, 202610
Oct 21, 202619
Oct 20, 202615
Oct 19, 202615
Oct 18, 202620
Oct 17, 202619
Oct 16, 202629
Oct 15, 202635
Oct 14, 202638
Oct 13, 202644
Oct 12, 202643
Oct 11, 202640
Oct 10, 202641
Oct 9, 202637
Oct 8, 202635
Oct 7, 202626
Oct 6, 202621
Oct 5, 202625
Oct 4, 202627
Oct 3, 202630
Oct 2, 202635
Oct 1, 202628
Sep 30, 202625
Sep 29, 202631
Sep 28, 202627
Sep 27, 202625
Sep 26, 202623
Sep 25, 202617
Sep 24, 202633
Sep 23, 202635
Sep 22, 202638
Sep 21, 202638
Sep 20, 202644
Sep 19, 202651
Sep 18, 202656
Sep 17, 202653
Sep 16, 202661
Sep 15, 202652
Sep 14, 202654
Sep 13, 202648
Sep 12, 202640
Sep 11, 202630
Sep 10, 202620
Sep 9, 202622
Sep 8, 202621
Sep 7, 202623
Sep 6, 202626

Each point is npm's rolling 7-day download count.

Health Score

50/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1216292583-root.svg)](https://payloaddirectory.dev/plugins/1216292583-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1216292583-root"><img src="https://payloaddirectory.dev/badge/1216292583-root.svg" alt="Payload Directory"></a>
Updated Jun 8, 2026Created Apr 20, 2026Published Jun 8, 2026

README

Payload Audit Logs

A Payload CMS plugin to automatically track and log CRUD operations (Create, Read, Update, Delete) on specified collections.

Features

  • Automatic Logging: Automatically creates audit logs for create, read, update, and delete operations.
  • Configurable: Choose which collections and which operations to track.
  • Historical Data: Stores both the originalData (before change) and newData (after change) for full auditability.
  • User Association: Automatically links logs to the user who performed the operation.
  • Easy Integration: Simple setup in your Payload configuration.

Installation

pnpm add payload-audit-logs
# or
npm install payload-audit-logs
# or
yarn add payload-audit-logs

Usage

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
})

Configuration

The plugin accepts the following options:

OptionTypeDefaultDescription
collectionsRecord<string, { operations: string[] }>{}A map of collection slugs to track and the operations to log for each.
disabledbooleanfalseIf true, the plugin will be disabled.
userCollectionstring'users'The slug of the collection used for users.
auditLogsAccessCollectionConfig['access']{ ... }Access control functions for the generated Audit Logs collection.
hideAuditLogsboolean | ((args: { user: PayloadRequest['user'] | null }) => boolean)falseHide the Audit Logs collection from the sidebar navigation.

Operations

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 read operation 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.

Code Sample

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',
    }),
  ],
})

Audit Logs Collection

When the plugin is enabled, it automatically adds an Audit Logs collection to your Payload admin panel.

Fields

  • Entity: The slug of the collection where the operation occurred.
  • Document ID: The ID of the affected document.
  • Operation: The type of operation performed (create, read, update, or delete).
  • User: A relationship to the user who performed the operation.
  • Original Data: (JSON) The data before the change occurred (available for update and delete).
  • New Data: (JSON) The data after the change occurred (available for create, read, and update).
  • Created At: Timestamp of when the log entry was created.

Access Control

By default:

  • Create/Update/Delete: Restricted (only the plugin can create logs).
  • Read: Any authenticated user can view audit logs.

You can fully customize these rules by providing the auditLogsAccess property in your plugin configuration.

Development

If you want to contribute or modify the plugin:

  1. Clone the repository.
  2. Install dependencies: pnpm install.
  3. Start the dev project: pnpm dev.
  4. Run tests: pnpm test.

License

MIT

Similar plugins