Configure Logging in MongoDB Community

June 25, 2024 ยท View on GitHub

This section describes the components which are logging either to a file or stdout, how to configure them and what their defaults are.

MongoDB Processes

Configuration

The exposed CRD options can be seen in the crd yaml. Additionally, more information regarding configuring systemLog can be found in the official documentation of systemLog]. spec.agent.systemLog.destination configures the logging destination of the mongod process.

Default Values

By default, MongoDB sends all log output to standard output.

MongoDB Agent

Configuration

spec.agent.logFile can be used to configure the output file of the mongoDB agent logging. The agent will log to standard output with the following setting: /dev/stdout.

Default Values

By default, the MongoDB agent logs to /var/log/mongodb-mms-automation/automation-agent.log

ReadinessProbe

Configuration & Default Values

The readinessProbe can be configured via Environment variables. Below is a table with each environment variable, its explanation and its default value.

Environment VariableExplanationDefault Value
READINESS_PROBE_LOGGER_BACKUPSmaximum number of old log files to retain5
READINESS_PROBE_LOGGER_MAX_SIZEmaximum size in megabytes5
READINESS_PROBE_LOGGER_MAX_AGEmaximum number of days to retain old log filesnone
READINESS_PROBE_LOGGER_COMPRESSif the rotated log files should be compressedfalse
MDB_WITH_AGENT_FILE_LOGGINGwhether we should also log to stdout (which shows in kubectl describe)true
LOG_FILE_PATHpath of the logfile of the readinessProbe./var/log/mongodb-mms-automation/readiness.log