审计日志
Page summary:审计日志捕获每一个可搜索、可过滤历史记录中的管理操作,以帮助排除故障和合规。在本指南中,示例展示了如何查看数据内容以及按用户或日期进行过滤。
审计日志功能提供可搜索和可过滤的显示,显示 Strapi 应用用户执行的所有活动。
🌐 The Audit Logs feature provides a searchable and filterable display of all activities performed by users of the Strapi application.

配置
🌐 Configuration
审计日志不是永久存档。超过保留期的日志会被自动删除。默认保留期为 90 天。
🌐 Audit Logs are not a permanent archive. Logs older than the retention period are deleted automatically. The retention period defaults to 90 days.
在保留期结束时删除的日志无法通过审核日志界面恢复。
🌐 Logs deleted at the end of the retention period cannot be recovered from the Audit Logs interface.
基于代码的配置
🌐 Code-based configuration
保 留期限是通过 /config/admin 文件的 auditLogs.retentionDays 参数来设置的。
🌐 The retention period is set with the auditLogs.retentionDays parameter of the /config/admin file.
如果许可证定义了保留期限,则适用许可证的数值,除非配置文件中定义了更小的值。
🌐 If the license defines a retention period, the license value applies, unless a smaller value is defined in the configuration file.
- JavaScript
- TypeScript
module.exports = ({ env }) => ({
// … other configuration properties
auditLogs: {
retentionDays: 30,
},
});
export default ({ env }) => ({
// … other configuration properties
auditLogs: {
retentionDays: 30,
},
});
在管理面板里没有对应的设置:保留期限只能在 /config/admin 文件里配置。
🌐 There is no equivalent setting in the admin panel: the retention period can only be configured from the /config/admin file.
/config/admin 文件也接受 auditLogs.enabled,当设置为 false 时会关闭审计日志,还有 auditLogs.exportMaxRows,它可以限制 导出。有关所有可用参数,请参阅 管理员面板配置。
🌐 The /config/admin file also accepts auditLogs.enabled, which turns off Audit Logs when set to false, and auditLogs.exportMaxRows, which limits exports. See the admin panel configuration for all available parameters.
使用
🌐 Usage
使用此功能的路径: 设置 > 管理面板 - 审计日志
审计日志功能记录以下事件:
🌐 The Audit Logs feature logs the following events:
| 事件 | 动作 |
|---|---|
| 管理员登录 / 登出 | success,error,autoRegistration |
| 审计日志 5.53.0+ | export |
| 组件 | create、update、delete |
| 内容类型 | create、update、delete |
| 条目(草稿/发布) | create、update、delete、publish、unpublish |
| 条目受让人 5.56.1+ | update |
| 条目审查阶段 5.56.1+ | updateEntryStage |
| 语言环境 5.54.0+ | create、update、delete、default.update |
| 媒体 | create、update、delete |
| 媒体文件夹 | create、update、delete |
| 版本 | create、update、delete、trigger |
| 发布条目 | add、update、remove |
| 发布设置 | update |
| 角色 / 权限 | create、update、delete |
| 用户 5.56.0+ | create,update,delete,password.update,password-reset.create,password-reset.confirm,invite.accept |
| 令牌 5.54.0+ | create、update、delete、regenerate |
| 网钩 | create、update、delete |
| 工作流 5.56.1+ | create、update、delete |
对于每个日志项,将显示以下信息:
🌐 For each log item, the following information is displayed:
- 操作:用户执行的操作类型(例如
create或update)。 - 日期:操作的日期和时间。
- 用户:执行操作的用户。
- 详情:显示一个模态窗口,提供关于该操作的更多详情(例如用户 IP 地址、请求体或响应体)。
在 Strapi 5.52.0 或更高版本中,已记录的操作可以来自管理面板或来自 MCP 服务器。通过 MCP 服务器执行的条目操作会像管理面板中的操作一样被记录。仅读取内容的操作不会被记录。
了解日志详情
🌐 Understanding log details
每种日志都会返回不同的详细信息,下面的部分会有解释。
🌐 Each type of log return different details, as explained in the following sections.
用户事件
🌐 User events
5.56.0This feature requires Strapi version 5.56.0 or later.用户事件涵盖管理员账户,记录为 admin-user.*。更新只记录发生变更的字段,包括名字、姓氏、邮箱、用户名、首选语言、活跃状态和角色。如果没有任何变化,则不会写入 任何行。
🌐 User events cover admin accounts, recorded as admin-user.*. An update records only the fields that changed, among first name, last name, email, username, preferred language, active status, and roles. No row is written when nothing changed.
管理员日志事件
🌐 Admin log events
管理员登录事件记录:
🌐 Admin login events record:
- 成功登录(
admin.auth.success), - 登录失败尝试(
admin.auth.error),记录失败原因(例如,invalid_credentials、account_inactive、sso_connection_error)以及使用的认证提供者 - 以及通过SSO自动注册(
admin.auth.autoRegistration)创建的新账户,这会记录SSO登录何时创建了新的管理员账户。
为了保护隐私,失败的登录和自动注册事件都会以未知用户的身份记录。
🌐 Both failed login and auto-registration events are recorded with an unknown actor to protect privacy.
密码事件
🌐 Password events
密码事件包括:
🌐 Password events cover:
- 从个人资料设置的密码或由另一个账户的管理员设置的密码(
password.update), - 从公共登录页面(
password-reset.create和password-reset.confirm)请求并确认了密码重置, - 以及接受的邀请(
invite.accept)。
密码、它的哈希值以及重置或注册令牌从来不会被记录。 这些密码重置和邀请操作不需要管理员会话,所以它们的用户列显示为 -。
🌐 The password, its hash, and reset or registration tokens are never recorded. These password reset and invitation actions happen with no admin session, so their User column shows -.
令牌事件
🌐 Token events
5.54.0This feature requires Strapi version 5.54.0 or later.令牌事件包括:
🌐 Token events cover:
每条日志都会标明它是哪种类型,更新则记录发生变化的字段,包括令牌名称、描述、类型和权限。访问密钥从不会被记录,包括在 regenerate 上。
🌐 Each log identifies which kind it was, and an update records the fields that changed, among the token name, its description, its type and its permissions. Access keys are never recorded, including on regenerate.
Webhook 事件
🌐 Webhook events
Webhook 事件会记录 webhook 的配置更改,包括 URL、头信息、事件和启用状态。为了保护敏感信息,webhook 的 URL 只会记录协议和主机部分(例如,用 https://hooks.example.com 代替完整带路径或查询参数的 URL),头信息的值从不记录,只记录头名称。update 事件会记录哪些字段发生了变化以及如何变化, 未改变的字段不会被包括在内。
🌐 Webhook events record configuration changes for webhooks, including the URL, headers, events, and enabled status. To protect sensitive information, webhook URLs are recorded as scheme and host only (for example, https://hooks.example.com instead of the full URL with path or query parameters), and header values are never recorded, only header names. An update event records which fields changed and how; unchanged fields are not included.
本地活动
🌐 Locale events
5.54.0This feature requires Strapi version 5.54.0 or later.本地化事件来自国际化设置。将某个本地化设置为默认会记录一个单独的locale.default.update事件,除此之外还有locale.create或locale.update事件。
🌐 Locale events come from Internationalization settings. Setting a locale as the default records a separate locale.default.update event, in addition to the locale.create or locale.update event.
查看工作流事件
🌐 Review workflows events
5.56.1This feature requires Strapi version 5.56.1 or later.工作流、条目审核阶段和条目分配事件来自审核工作流。工作流事件记录对工作流配置的更改。条目审核阶段和条目分配事件记录对单个条目的更改。有关每个事件记录内容,请参见审核工作流操作的审计日志。
🌐 Workflow, entry review stage and entry assignee events come from Review Workflows. Workflow events record changes to a workflow configuration. Entry review stage and entry assignee events record changes made to a single entry. See audit logging of review workflow actions for what each one records.
正在访问日志详情
🌐 Accessing log details
对于任何日志项,点击 图标即可访问一个包含该操作更多详细信息的模态窗口。在模态窗口中,Payload 部分以交互式 JSON 组件显示详细信息,使你可以展开和折叠 JSON 对象。

在 Strapi 5.52.0+ 中,payload 里的 origin 键表示这个操作是从哪里来的:
来源为 scheduler 的操作没有用户,所以它们的用户列显示为 -。审核日志中记录了发布计划安排时的条目,可以明确是谁安排的。
🌐 Actions with the scheduler origin have no user, so their User column shows -. The audit log entry recorded when the release was scheduled identifies who scheduled it.
过滤日志
🌐 Filtering logs
默认情况下,所有日志按时间倒序显示。你可以按以下方式筛选日志:
🌐 By default, all logs are displayed in reverse chronological order. You can filter the logs by:
- 操作:选择要过滤的操作类型(例如
create或update)。 - 用户:选择要筛选的用户。
- 日期:选择要筛选的日期(范围)和时间。

动作过滤器还会匹配在此格式之前使用的旧版 user.create、user.update 和 user.delete 值,所以旧行和新行会一起显示。
🌐 The Action filter also matches the legacy user.create, user.update and user.delete values used before this format, so old and new rows appear together.
导出审计日志
🌐 Exporting audit logs
5.53.0This feature requires Strapi version 5.53.0 or later.拥有 export 权限的用户可以将当前筛选的审计日志条目导出为 CSV 文件。要使用此功能,用户的角色必须在 设置 > 管理面板 > 角色 > 审计日志 中同时拥有 读取 和 导出 权限(参见 管理面板配置)。
🌐 Users with the export permission for Audit Logs can export the current filtered set of entries as a CSV file. To access this feature, the user's role must have both the Read and Export permissions under Settings > Administration Panel > Roles > Audit Logs (see admin panel configuration).
要导出审计日志:
🌐 To export audit logs:
- (可选)应用筛选器以选择要导出的条目。
- 点击 导出为 CSV 开始预下载文件。预下载完成前请保持浏览器标签页打开。
- 点击 下载 CSV 保存导出的文件。
每次导出都会被记录为一个 audit-log.export 事件。这个事件会被包含在导出的 CSV 文件中。
🌐 Every export is itself recorded as an audit-log.export event. This event is included in the exported CSV file.
默认情况下,导出最多限制为 1,000,000 行。要更改此限制,请在管理面板配置中设置 auditLogs.exportMaxRows 参数。
🌐 By default, exports are limited to 1,000,000 rows. To change this limit, set the auditLogs.exportMaxRows parameter in the admin panel configuration.