Hi there
How can I reduce logging of MongoDB in Docker?
I tried the following:
`command: mongod --quit ``` // did not work
I tried:
command: mongod --config /etc/mongo/mongo.conf
with the following mongo.conf
:
systemLog:
verbosity: 0
quiet: true
component:
accessControl:
verbosity: -1 # Suppress ACCESS logs
network:
verbosity: -1 # Suppress NETWORK logs
I verified that these settings were taking into account:
`
logComponentVerbosity: {
verbosity: 0,
accessControl: { verbosity: -1 },
assert: { verbosity: -1 },
command: { verbosity: -1 },
control: { verbosity: -1 },
executor: { verbosity: -1 },
geo: { verbosity: -1 },
globalIndex: { verbosity: -1 },
index: { verbosity: -1 },
network: {
verbosity: -1,
asio: { verbosity: -1 },
bridge: { verbosity: -1 },
connectionPool: { verbosity: -1 }
},
processHealth: { verbosity: -1 },
query: { verbosity: -1 },
queryStats: { verbosity: -1 },
replication: {
verbosity: -1,
election: { verbosity: -1 },
heartbeats: { verbosity: -1 },
initialSync: { verbosity: -1 },
rollback: { verbosity: -1 }
},
sharding: {
verbosity: -1,
rangeDeleter: { verbosity: -1 },
shardingCatalogRefresh: { verbosity: -1 },
migration: { verbosity: -1 },
reshard: { verbosity: -1 },
migrationPerf: { verbosity: -1 }
},
storage: {
verbosity: -1,
recovery: { verbosity: -1 },
journal: { verbosity: -1 },
wt: {
verbosity: -1,
wtBackup: { verbosity: -1 },
wtCheckpoint: { verbosity: -1 },
wtCompact: { verbosity: -1 },
wtEviction: { verbosity: -1 },
wtHS: { verbosity: -1 },
wtRecovery: { verbosity: -1 },
wtRTS: { verbosity: -1 },
wtSalvage: { verbosity: -1 },
wtTiered: { verbosity: -1 },
wtTimestamp: { verbosity: -1 },
wtTransaction: { verbosity: -1 },
wtVerify: { verbosity: -1 },
wtWriteLog: { verbosity: -1 }
}
},
write: { verbosity: -1 },
ftdc: { verbosity: -1 },
tracking: { verbosity: -1 },
transaction: { verbosity: -1 },
tenantMigration: { verbosity: -1 },
test: { verbosity: -1 },
resourceConsumption: { verbosity: -1 }
},
ok: 1
}
I tried 5 other things without success - these logs keep getting in my docker container:
unifi-db | {"t":{"$date":"2025-01-11T10:33:39.569+00:00"},"s":"I", "c":"ACCESS", "id":6788604, "ctx":"conn12","msg":"Auth metrics report","attr":{"metric":"acquireUser","micros":0}}
unifi-db | {"t":{"$date":"2025-01-11T10:33:39.593+00:00"},"s":"I", "c":"ACCESS", "id":5286306, "ctx":"conn12","msg":"Successfully authenticated","attr":{"client":"172.25.0.1:51300","isSpeculative":true,"isClusterMember":false,"mechanism":"SCRAM-SHA-256","user":"unifi","db":"admin","result":0,"metrics":{"conversation_duration":{"micros":23599,"summary":{"0":{"step":1,"step_total":2,"duration_micros":177},"1":{"step":2,"step_total":2,"duration_micros":23}}}},"extraInfo":{}}}
unifi-db | {"t":{"$date":"2025-01-11T10:33:39.706+00:00"},"s":"I", "c":"NETWORK", "id":6788700, "ctx":"conn12","msg":"Received first command on ingress connection since session start or auth handshake","attr":{"elapsedMillis":113}}
Here is part of my docker-compose:
unifi-db:
image: docker.io/mongo:7.0.16
container_name: unifi-db
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=v3ryDifficultPa55word
- MONGO_USER=unifi
- MONGO_PASS=****
- MONGO_DBNAME=unifi
- MONGO_AUTHSOURCE=admin
volumes:
- ./mongo/data/:/data/db
- ./mongo/mongo.conf:/etc/mongo/mongo.conf:ro
- ./mongo/init-mongo.sh:/docker-entrypoint-initdb.d/init-mongo.sh:ro
command: mongod --config /etc/mongo/mongo.conf
shm_size: '256mb'
restart: unless-stopped
ports:
- 27017:27017
attach: false
healthcheck:
test: |
mongosh --eval "db.adminCommand('ping').ok" --quiet > /dev/null 2>&1 || exit 1
interval: 10s
timeout: 10s
retries: 5
start_period: 40s