I am using MongoDB 3.0 official docker image , in the configuration option it says the logs are being persisted in /var/log/mongodb/mongod.log but when i navigate to /var/log/mongodb/ there is no such file.
I am using the default mongo configuration.
This is what i got in my init.d file
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
But no logs are being logged , am i looking in wrong place or do i need to enable any other setting for this?
We don't use any configuration file by default, and logs should be going to stdout, and thus available via docker logs your-mongodb-container -- if that's not the desired behavior, you should be able to provide flags to the container's startup to modify the behavior (docker run ... mongo --logpath /somewhere/specific.log).
@tianon Cool makes sense , is it right that mongo use journal for loggings which can then be accessed via docker logs
Are these journal logs are stored for ever in the container?
@sri85 You might be confused with mongodb's "journal" file and "log" file. mongodb by default writes to a journal file for durability. When run mongod with a config file, log files can be optionally kept within the container, or use docker's VOLUME option to store log files on host or another container. If store log file within the container, you can config mongod to reopen existing log file or rename to a new log file .
@dbsrv Thanks for the clarification :)
Closing old issue. Feel free to comment on further troubleshooting if you feel this was closed in error or on the solution to help users running into the same problem.
@tianon Is it possible to provide that flag in a docker-compose file, I've tried over command, but it's acting strangely, considering my .log file as a directory. When I provide the flag in docker run it does work though (with the same image and port etc.)
@ivorbaric yeah, you just have to be careful about YAML syntax so you don't get sh -c ... added -- I'd recommend using the array syntax, ala:
services:
mongo:
image: mongo:4.x
command: ['--logpath', '/somewhere/specific.log']
or:
services:
mongo:
image: mongo:4.x
command:
- '--logpath'
- '/somewhere/specific.log'
Most helpful comment
@ivorbaric yeah, you just have to be careful about YAML syntax so you don't get
sh -c ...added -- I'd recommend using the array syntax, ala:or: