Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB not logging to log file

Tags:

mongodb

I'm using MongoDB on OSX, with mongod confirmed running. I checked the mongod.conf file and the following is present and unmodified:

systemLog:
  destination: file
  path: /usr/local/var/log/mongodb/mongo.log
  logAppend: true

So far so good. The path location exists, however the folder is empty - no mongo.log. This was a standard installation and everything has been fine so far except this. Any idea on how to troubleshoot this issue?

like image 696
ugotchi Avatar asked Mar 12 '23 11:03

ugotchi


1 Answers

Context

I deleted my mongod.log file once. Then I recreated it and ran into this exact problem. I may have deleted the /var/log/mongodb folder as well, then recreated it.

I was reading under Run Mongodb Community Edition:

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

The MongoDB instance stores its data files in /var/lib/mongodb and its log files in /var/log/mongodb by default, and runs using the mongodb user account.

I read into this way too much and assumed the user who starts the mongodb service is the "mongodb user account". This is incorrect. They literally mean the user: mongodb

Solution

sudo chown mongodb /var/log/mongodb
like image 157
Benjamin Avatar answered Mar 30 '23 19:03

Benjamin