How to configure logration on linux

Hi all,

I want to configure logrotate on my Linux server to have a rotation and suppression of the old log file. My mongod.conf file is set as follow:

where to write logging data.

systemLog:
destination: file
logAppend: false
path: /var/log/mongodb/mongod.log

And the logrotate for MongoDB is :

cat /etc/logrotate.d/mongodb
/var/log/mongodb/mongod.log {
daily
rotate 7
compress
missingok
notifempty
copytruncate
delaycompress
postrotate
/bin/kill -SIGUSR1 $(pidof mongod) # Notify MongoDB to reopen logs
endscript
}

I would like know if it is correct ? I’m not sure that’s work correctly.

Thanks for your help
Olivier

Hi @Olivier_Studer

The following page outlines the options to use with logRotate:
https://www.mongodb.com/docs/manual/tutorial/rotate-log-files/#log-rotation-with—logrotate-reopen

Change logAppend to true and add logRotate: reopen and this will work well with logrotate.

copytruncate should be removed from the logrotate config.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.