Enable auditing in MongoDB
While auditing can be enabled in an environment without authentication, it is most beneficial when used in conjunction with authentication. This allows you to track who performed certain operations on your database in addition to what operations were performed. In this section, you will learn about various configuration file parameters that are required to enable auditing.
First, you'll need to specify where the audit logs will be stored. Depending on the needs of the organization and environment, MongoDB offers different output formats for audit logs. For this example, use the storage.auditLog
section.
- Console:
- MongoDB can send audit logs directly to standard output (
stdout
). - This is useful for testing, or in scenarios where you have an external tool capturing standard output for further processing.
storage: dbPath: data/db auditLog: destination: console
- MongoDB can send audit logs directly to standard output (
- JSON:
- Audit records can be formatted as...