Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

Status Completed
Categories MongoDB Shell
Created by Guest
Created on Oct 18, 2022

Control logging behavior of mongosh

It should be possible to control the logging behavior of mongosh, for example: - verbosity - what to log / log level - retention time - whether logging is enabled or not
  • ADMIN RESPONSE
    Oct 18, 2025
    Hi all, based on your feedback, I'm excited to announce the latest round of logging enhancements we've made in mongosh, available starting mongosh v2.4.0: - Disable logging altogether: https://www.mongodb.com/docs/mongodb-shell/logs/disable/#std-label-mongosh-logs-disable - Specify a custom log file location: https://www.mongodb.com/docs/mongodb-shell/logs/location/#std-label-mongosh-log-location - Enable log compression: https://www.mongodb.com/docs/mongodb-shell/logs/compression/#std-label-mongosh-log-compression - Specify maximum log storage size: https://www.mongodb.com/docs/mongodb-shell/logs/retention/size/#std-label-mongosh-log-retention-gb - Modify maximum log file count: https://www.mongodb.com/docs/mongodb-shell/logs/retention/size/#std-label-mongosh-log-retention-gb - Modify log retention duration: https://www.mongodb.com/docs/mongodb-shell/logs/retention/size/#std-label-mongosh-log-retention-gb - Ability to write custom log entries: https://www.mongodb.com/docs/mongodb-shell/logs/custom-entries/#std-label-mongosh-custom-log-entries You can download the latest version of mongosh from the download center: https://www.mongodb.com/try/download/shell. Please let us know if you have any additional feedback!
  • Guest
    Sep 20, 2024
    We are having problems with the Mongo Shell tool's logs, now it is impacting us as the operating system is running out of space. It should be possible to control the amount and location of logging. Please fix.
  • Guest
    Sep 19, 2024
    As a workaround, one way is to remove write permissions to the mongosh directory with "chmod 500 " or equivalent. Another is to run a cron job to periodically remove files ending in _log in that directory.
  • Guest
    Apr 8, 2024
    In some cases, it's very important to us to be able di disable any log.
  • Guest
    Jan 12, 2024
    "mongosh retains log files for 30 days. Log files older than 30 days are automatically deleted." I would like to control the number of days, for it is critical.
  • Guest
    Jan 8, 2024
    We will have to make provisions to deal with the level of verbosity of the mongosh. It should be possible to control the amount and location of logging. Please fix.
  • Guest
    Dec 14, 2023
    The current logging verbosity is very high. We are constantly in the danger of running out of disk space due to the mongosh log stored in the user's home directory. The only solution we have currently is to set up a corn job to delete logs every hour. Please fix this.
  • Guest
    Dec 9, 2022
    we use mongosh as part of our application deployment process where we checkout release-specific artifacts from source code control, build a "work file (.js)" of all changes for the release, then execute that script by piping it into the mongosh. We are not able to retrieve commands or return results of the commands indicating success/failure. Instead, we see something like: Atlas [mongos] test> myDB Atlas [mongos] myDB> ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... Atlas [mongos] myDB> ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... Atlas [mongos] myDB> ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... Atlas [mongos] myDB> ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... Atlas [mongos] myDB> Atlas [mongos] myDB> ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... More control over command capture and result verbosity is critical to determining success/failure of a deployment.