如何禁用 MongoDB 的日志记录? [英] How can I disable the logging of MongoDB?

查看:181
本文介绍了如何禁用 MongoDB 的日志记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 MongoDB 日志文件超过 16GB,日志文件对我来说并不重要.如何禁用 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?

推荐答案

关闭日志记录并不是一个明智的主意.使用轮换日志文件来轮换它们并保持它们较小.

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

logrotate 是 Linux 上的标准功能.

logrotate is standard function on Linux.

旋转日志文件的最简单方法是 kill -USR1 $(/usr/sbin/pidof mongod)

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

我的 logrotate.conf 文件如下所示:

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
}

当日志文件达到 10MB 时,它就会被轮换.最多可保存 9 个文件.logrotate 由每日 cron 作业执行.

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.

这篇关于如何禁用 MongoDB 的日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆