strapi-plugin-logz
v0.1.0
Published
Automatically capture and record the API calls made to your Strapi application
Readme
Strapi Plugin Logz
Automatically capture and record the API calls made to your Strapi application

💸 Support Me
If you can 😊
⚙️ Version
This plugin is compatible with Strapi v5.
💻 Prerequisites
- Node v20+ (I recommend using nvm, there is a windows and mac/linux version)
- A Strapi v5 project (
npx create-strapi-app@latest my-project)
⬇️ Installation
Install the plugin by running the following command:
npm install strapi-plugin-logz🎚️ Plugin Configuration
All options are optional.
// config/plugins.ts
export default ({ env }) => ({
logz: {
enabled: true,
config: {
// Skip logging for these APIs or plugins (by name).
// "car" skips every request sent to /api/cars
skipList: ["car", "upload"],
// Skip logging for these route paths (as defined in Strapi, without the /api prefix)
skipEndpoints: ["/auth/local", "/articles/:id"],
// Delete logs older than 90 days
retentionDays: 90,
// Also store request bodies, without these keys
logRequestBody: true,
redactKeys: ["phoneNumber"],
},
},
});| Option | Type | Default | Description |
| ---------------- | ---------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| skipList | string[] | [] | API names (e.g. article) or plugin names (e.g. users-permissions) to skip |
| skipEndpoints | string[] | [] | Route paths to skip, e.g. /auth/local or /articles/:id |
| retentionDays | number \| null | null | Delete logs older than this many days. Runs 30 seconds after startup, then every hour. null keeps logs forever |
| logOwnRequests | boolean | false | Also log requests made to the Logz REST API (/api/logz/...) |
| logIpAddress | boolean | true | Store the client's IP address. Behind a reverse proxy, enable Strapi's proxy server option so the client's IP is used |
| logRequestBody | boolean | false | Store request bodies. Passwords, tokens and redactKeys are removed; bodies over 10,000 characters are replaced with a placeholder |
| redactKeys | string[] | [] | Extra keys removed from stored request and response bodies, at any depth (case insensitive) |
The LogzConfig type is exported if you want to type your configuration:
import type { LogzConfig } from "strapi-plugin-logz/strapi-server";▶️ Usage
After installing, you can access the Logz Dashboard by navigating to the Logz section in the admin panel.
- Dashboard: totals and charts for the last 7 days or 7 months.
- View logz: a searchable list of every log. Filter by method, status (
2xx,4xx, ...) and date, search by URL, action, user, IP or API token, sort by date or duration, and open a log to see everything that was stored. - Download logz: export the logs for a date range as CSV.


🔐 Permissions
- Admin dashboard: give a role the
Allow Logz dashboard accesspermission in Settings → Administration Panel → Roles → Plugins → Logz. Super Admins have it by default. The dashboard API (/logz/*) requires an authenticated admin with this permission. - REST API: the content API routes (
/api/logz/*) are disabled by default. Enable the ones you need for a role in Settings → Users & Permissions plugin → Roles → Logz.
📝 What gets logged
Every request to the content API (/api/*, or your custom api.rest.prefix) is logged after it is handled. Admin panel requests are not logged. Logs are written in the background, so logging never slows down or breaks a request.
Each log stores:
- the method, URL, status code and a readable action (e.g.
Created a new Article,Logged in) - who made the request: the user (including the user who just logged in or registered) or the name of the API token
- how long the request took, the IP address and the user agent
- the request body, when
logRequestBodyis enabled - some data about the response:
- List requests (
GETwithout route params): a summary (5 record(s) fetched) and the query, not the full payload. - Other successful requests: the response body.
- Failed requests (status 400+): the error response.
- Non-JSON responses (files, streams): a placeholder.
- List requests (
Tokens and passwords (jwt, token, refreshToken, password, ...) and your redactKeys are removed from stored bodies at any depth.
Requests to the Logz REST API itself are not logged unless logOwnRequests is enabled.
🌐 REST API
| Method | Path | Description |
| ------ | ------------------------------ | ------------------------------------------------------------------------------------ |
| GET | /api/logz | List logs. Supports the usual filters, sort, pagination, populate |
| GET | /api/logz/:id | Get one log by id or documentId |
| GET | /api/logz/download | Download logs as CSV (streamed). Optional start & end (YYYY-MM-DD or ISO date) |
| GET | /api/logz/dashboard-totals | Total requests, logins, registrations and errors |
| GET | /api/logz/requests-over-time | Requests per day/month. filterBy=week (default) or month |
| GET | /api/logz/login-vs-register | Logins vs registrations per day/month. filterBy=week or month |
| GET | /api/logz/most-accessed | Requests per method for the period. filterBy=week or month |
🚀 Services
Find
await strapi.plugin("logz").service("logz").find(QUERY_PARAMS_OBJECT);FindOne
await strapi.plugin("logz").service("logz").findOne(ID, QUERY_PARAMS_OBJECT);Delete old logs
// Delete every log created before a date
await strapi.plugin("logz").service("logz").deleteBefore(new Date("2025-01-01"));
// Apply the `retentionDays` configuration now
await strapi.plugin("logz").service("logz").applyRetention();Count
await strapi
.plugin("logz")
.service("logz")
.count({ where: { method: "GET" } });📝 License
This project is licensed under the MIT License - see the LICENSE file for details
