A comprehensive audit logging plugin for Strapi v5 that tracks all user interactions and system events with a clean admin interface and automatic cleanup.
β οΈ Version Compatibility
- v2.x: Supports Strapi v5 only
- v1.x: Supports Strapi v4 only
If you're using Strapi v4, please install v1.x:
npm install strapi-plugin-audit-logs@^1.0.0
- π Comprehensive Logging: Track content operations, media uploads, user management, and authentication events
- π― Smart Event Tracking: Automatically logs content creation, updates, deletions, publishing, and more
- π Data Security: Configurable sensitive data redaction
- ποΈ Rich Admin UI: Beautiful interface with filtering, search, pagination, and detailed log views
- π§Ή Automatic Cleanup: Configurable log retention with manual cleanup option
- π Detailed Logging: Captures user info, IP addresses, HTTP context, and operation details
- π Role-Based Permissions: Granular access control with super admin cleanup controls
npm install strapi-plugin-audit-logs@^2.1.0yarn add strapi-plugin-audit-logs@^2.1.0After installation, configure the plugin in your config/plugins.js (or config/plugins.ts for TypeScript):
module.exports = {
"audit-logs": {
enabled: true,
config: {
enabled: true,
deletion: {
enabled: true,
frequency: "logAge", // 'logAge' or 'logCount'
options: {
value: 90, // Keep logs for 90 days
interval: "day", // 'day', 'week', 'month', 'year'
},
},
excludeContentTypes: [
"plugin::any-custom-type.any-custom-type",
],
excludeEndpoints: [
"/admin/renew-token",
"/api/upload",
"/api/any-custom-type/any-custom-route",
],
redactedValues: [
"password",
"token",
"jwt",
"authorization",
"secret",
"key",
"private",
],
events: {
track: [
"entry.create",
"entry.update",
"entry.delete",
"entry.publish",
"entry.unpublish",
"media.create",
"media.update",
"media.delete",
"media-folder.create",
"media-folder.update",
"media-folder.delete",
"user.create",
"user.update",
"user.delete",
"role.create",
"role.update",
"role.delete",
"admin.auth.success",
"admin.auth.failure",
"admin.logout",
],
},
adminPanel: {
indexTableColumns: [
"action",
"date",
"user",
"method",
"status",
"ipAddress",
"entry",
],
},
},
},
};For TypeScript projects, create or update config/plugins.ts:
export default {
"audit-logs": {
enabled: true,
config: {
// ... same configuration as above
},
},
};-
Install the plugin using npm or yarn (see installation section above)
-
Configure the plugin in
config/plugins.jsorconfig/plugins.ts -
Restart your Strapi application:
npm run develop # or yarn develop -
Set up permissions in the Strapi admin panel:
- Go to Settings β Roles
- Edit the roles that should have access to audit logs
- Enable "View Audit Logs" permission for the Audit Logs plugin
- Type:
boolean - Default:
true - Description: Enable/disable the entire plugin
Configure automatic log cleanup:
- enabled:
boolean- Enable automatic cleanup (runs daily at midnight) - frequency:
'logAge' | 'logCount'- Cleanup strategy - options:
- For
logAge:{ value: 90, interval: 'day' }(delete logs older than 90 days) - For
logCount:{ value: 1000 }(keep only latest 1000 logs)
- For
Array of API endpoints to exclude from logging. Supports:
- Exact matches:
/api/my-custom-endpoint - Prefix matches:
/admin/renew-token(matches/admin/renew-token/anything) - Wildcards:
/api/upload/*(matches any endpoint starting with/api/upload/)
Array of content type UIDs to exclude from logging (e.g., ["api::private-content.private-content"])
Array of field names to redact in logged data for security purposes.
Configure automatic event tracking:
- track:
string[]- Array of events to log automatically
Configure the audit-log list view:
- indexTableColumns:
('action' | 'date' | 'user' | 'method' | 'status' | 'ipAddress' | 'entry')[] - Default:
["action", "date", "user", "method", "status", "ipAddress", "entry"] - Description: Controls which data columns are rendered in the audit log table. The details/actions column is always displayed and cannot be removed.
The plugin automatically tracks these system events:
entry.create- Content entry createdentry.update- Content entry updatedentry.delete- Content entry deletedentry.publish- Content entry publishedentry.unpublish- Content entry unpublished
media.create- Media file uploadedmedia.update- Media file updatedmedia.delete- Media file deletedmedia-folder.create- Media folder createdmedia-folder.update- Media folder updatedmedia-folder.delete- Media folder deleted
user.create- User account createduser.update- User account updateduser.delete- User account deleted
role.create- Role createdrole.update- Role updatedrole.delete- Role deleted
admin.auth.success- Successful admin loginadmin.auth.failure- Failed admin login attemptadmin.logout- Admin logout
- Navigate to the Strapi admin panel
- Look for "Audit Logs" in the main navigation menu
- Click to view the audit logs interface
The audit logs interface provides:
- Table View: See all logs with configurable columns for action, date, user, method, status, IP address, and direct entry links
- Action Filter: Dropdown to filter by specific action types
- User Search: Text input to search by username or email
- Advanced Pagination: Page size selector (10, 25, 50, 100) with smart navigation
- Details Modal: Click "View" to see full log details including JSON payload data
If adminPanel.indexTableColumns includes entry, entry-related logs with a known content type UID and document ID will show an Open Entry button that links directly to the Content Manager edit view.
Each log entry contains:
-
Action: The type of action performed (with color-coded badges)
-
Date: When the action occurred
-
User: Who performed the action (username/email)
-
Method: HTTP method used (GET, POST, PUT, DELETE)
-
Status Code: Response status code (with color coding)
-
IP Address: Client IP address
-
User Agent: Client browser/application
-
Payload Data: Full operation details in JSON format
Super administrators can manually trigger log cleanup by clicking the "Cleanup Old Logs" button in the interface.
The plugin uses a role-based permission system:
- View Audit Logs: Basic access to view the audit logs page and browse logs
- View Details: Access to detailed log information (available to all users with read access)
- Cleanup: Manual cleanup functionality (super administrators only)
To grant access:
- Go to Settings β Roles
- Select the role to modify
- Under "Plugins" β "Audit Logs", enable "View Audit Logs"
- Cleanup functionality is automatically available to super administrators
The plugin provides these API endpoints (admin authentication required):
GET /admin/audit-logs- List audit logs with filtering and paginationGET /admin/audit-logs/:id- Get specific log detailsGET /admin/audit-logs/count- Count total logsGET /admin/audit-logs/config- Get admin panel table configurationPOST /admin/audit-logs/cleanup- Trigger manual cleanup (super admin only)
The plugin creates an audit_logs table with these fields:
| Field | Type | Description |
|---|---|---|
id |
Primary Key | Unique identifier |
documentId |
String | Document identifier (Strapi v5) |
action |
String | Action performed (e.g., entry.create, media.delete) |
date |
DateTime | Timestamp of the action |
payload |
JSON | Operation details and context |
userId |
Integer | User ID (if authenticated) |
userDisplayName |
String | User display name |
userEmail |
String | User email |
endpoint |
String | API endpoint accessed |
method |
String | HTTP method (GET, POST, PUT, DELETE) |
statusCode |
Integer | HTTP response status code |
ipAddress |
String | Client IP address |
userAgent |
Text | Client user agent string |
- Sensitive data is automatically redacted based on configuration
- Logs are only accessible to users with proper permissions
- IP addresses and user agents are logged for security auditing
- Cleanup functionality restricted to super administrators
- Consider log retention policies for compliance requirements
- Ensure the plugin is enabled in
config/plugins.js - Restart Strapi after configuration changes
- Check that your user role has the "View Audit Logs" permission
- Verify
enabled: truein plugin configuration - Check that the events you want to track are in the
events.trackarray - Restart Strapi after configuration changes
- Look for error messages in Strapi logs
- Reduce the number of tracked events in configuration
- Decrease log retention period for faster cleanup
- Use
logCountcleanup strategy for high-traffic sites
- Strapi: 5.x
- Node.js: 18.x, 20.x, 22.x
- Database: PostgreSQL, MySQL/MariaDB, SQLite
- Operating System: Windows, macOS, Linux
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This plugin was inspired by Strapi Enterprise Edition's audit logs feature and the community plugin by Marje3PSUT.
If you encounter any issues or have questions:
- Check the troubleshooting section
- Search existing GitHub issues
- Create a new issue if needed