Database Manual / Reference / Database Commands / Auditing

logApplicationMessage (database command数据库命令)

Definition定义

logApplicationMessage
The logApplicationMessage command allows users to post a custom message to the audit log. logApplicationMessage命令允许用户将自定义消息发布到审核日志中。If running with authorization, users must have clusterAdmin role, or roles that inherit from clusterAdmin, to run the command.如果使用授权运行,则用户必须具有clusterAdmin角色或从clusterAdmin继承的角色才能运行该命令。

Compatibility兼容性

This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:

  • MongoDB Enterprise: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本
  • MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本

Syntax语法

The command has the following syntax:该命令具有以下语法:

db.runCommand(
{
logApplicationMessage: <string>
}
)

Behavior行为

MongoDB associates these custom messages with the audit operation applicationMessage, and the messages are subject to any filtering.MongoDB将这些自定义消息与审计操作applicationMessage相关联,并且这些消息会受到任何筛选