NoneS
NoneS

Reputation: 19

How can I disable the logging of MongoDB?

My MongoDB Log file is over 16GB, the log file is not important to me. How can I disable the logging of MongoDB and if I do, will I encounter any problems?

Upvotes: 0

Views: 2709

Answers (1)

Wernfried Domscheit
Wernfried Domscheit

Reputation: 59602

It would not be a smart idea to turn off logging. Use Rotate Log Files to rotate them and keep them small.

logrotate is standard function on Linux.

Simplest way to rotate the log file is kill -USR1 $(/usr/sbin/pidof mongod)

My logrotate.conf file looks like this:

missingok
compress
delaycompress
notifempty
create

/var/log/mongodb/mongod.log{
  size 10M
  rotate 9
  sharedscripts
  postrotate
    kill -USR1 $(/usr/sbin/pidof mongod)
  endscript
}

When the logfile reaches 10MB then it is rotated. Up to 9 files are kept. logrotate is executed by a daily cron job.

Though you can disable logging, it is really not recommended.

Upvotes: 1

Related Questions