Docs Menu
Docs Home
/
MongoDB Shell
/ /

Disable Logging

On this page

  • About this Task
  • Before you Begin
  • Steps

To specify whether MongoDB Shell writes log messages, use the disableLogging configuration option. Logging is enabled by default.

When you toggle logging, the change affects the current MongoDB Shell session. You don't need to start a new session for the change to take effect.

To check if logging is currently disabled, run the following command:

config.get("disableLogging")
  • If the command returns true, logging is disabled.

  • If the command returns false, logging is enabled.

You can set the disableLogging configuration option with the configuration API or a configuration file.

The following command uses the config API to disable logging for MongoDB Shell:

config.set("disableLogging", true)
Setting "disableLogging" has been changed

The following configuration file disables logging for MongoDB Shell:

mongosh:
disableLogging: true

To enable logging, set disableLogging to false. You can perform this action through the config API or configuration file.

Back

Enable Log Compression