如何禁用 MongoDB 的日志记录?

编程入门 行业动态 更新时间:2024-10-08 08:25:05
本文介绍了如何禁用 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 的日志记录?

本文发布于:2023-11-25 21:28:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631416.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日志   MongoDB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!