MongoDB log files are too large to handle

  • 2020-05-14 05:19:30
  • OfStack

With logappend=true, the log files of MongoDB will be constantly added to the same log files. After a long time, the log files of MongoDB will naturally become very large.

The solution is as follows: (special note: the startup must be --logpath specifies the log path)

Connect to the server using mongo


use admin  // Switch to the admin The database
db.runCommand({logRotate:1})

This will cause mongo to close the current log file and restart a new log file without stopping the mongodb service.


Related articles: