'How to reduce mongo log verbosity in a docker-compose image?
I'm running MongoDB inside a larger server, controlled by docker-compose.
I'd like to reduce the verbosity of the Mongo logs (and probably eventually control other Mongo settings too). Not sure where to fit this into my minimal config; I currently just have:
mongo:
image: mongo:3.2
volumes:
- ${MONGO_DATA_DB}:/data/db
ports:
- ${EXPOSED_MONGO_PORT}:27017
Solution 1:[1]
I've tried the accepted answer but mongo log was still quite verbose. Then, following this thread, I've omitted the whole log and it's much better in my case:
mongo:
command: mongod --quiet --logpath /dev/null
Solution 2:[2]
Setting logpath worked for me. It's not showing the logs output instead it's saving to the file.
mongo:
container_name: mongo
image: mongo
restart: unless-stopped
command:
- '--logpath'
- '/var/log/mongodb/mongod.log'
ports:
- '27017:27017'
Solution 3:[3]
An alternative MongoDB image by Bitnami offers this functionality via environment variables in compose file.
https://hub.docker.com/r/bitnami/mongodb. Explained in the section Configuring system log verbosity level
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Carlos Bazilio |
| Solution 2 | Hasip Timurtas |
| Solution 3 | Emre Sülün |
