1

We are using MongoDB 4.0.4 version for our project. The database configuration is done as below:

  1. Created a custom database in MongoDB and the service is running in authentication mode.
  2. Using Windows systems (Server and Desktop both)

We have observed that the MongoDB log file size gets increased over the period and consumes disk space in GBs. Mongo creates a new log file only after the MongoDB service is rebooted. Due to the large size issue, we want to do either:

  1. Control the entries in the log file (We have tried by setting different verbose levels)
  2. Use logrotate command (The command doesn't work on Windows as intended, though we have read it on forums that it supports only Linux)
  3. Delete log files (We can manually delete all log files, but when we try to delete it programmatically through windows service, it only deletes backup files, but the active file gives an error as file in use)

Is there any other solution that we can try? Thanks in advance.

1 Answer 1

1

You need to run db.adminCommand({logRotate: <target>})

see https://www.mongodb.com/docs/manual/reference/command/logRotate/

In deed, the Linux logrotate is much more powerful and flexible. In Windows you have to write your own scripts for cleanup, compression, etc. (e.g. with Powershell) - unfortunately.

You may find some "logrotate für Windows" tools in the internet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.