MongoDB log file growth

后端 未结 4 517
野性不改
野性不改 2020-12-13 04:45

Currently my log file sits at 32 meg. Did I miss an option that would split the log file as it grows?

4条回答
  •  攒了一身酷
    2020-12-13 05:06

    You can use logrotate to do this job for you.

    Put this in /etc/logrotate.d/mongod (assuming you use Linux and have logrotated installed):

    /var/log/mongo/*.log {
        daily
        rotate 30
        compress
        dateext
        missingok
        notifempty
        sharedscripts
        copytruncate
        postrotate
            /bin/kill -SIGUSR1 `cat /var/lib/mongo/mongod.lock 2> /dev/null` 2> /dev/null || true
        endscript
    }
    

提交回复
热议问题