Docs Menu
Docs Home
/
MongoDB Shell
/

Configure Settings

On this page

  • Configurable Settings
  • How to Configure Settings

To specify certain shell behaviors, you can configure mongosh settings.

You can configure the following settings for mongosh:

Key
Type
Default
Description

disableLogging

boolean

false

Specifies whether MongoDB Shell writes log entries.

displayBatchSize

integer

20

The number of items displayed per cursor iteration

enableTelemetry

boolean

true

Enables sending anonymized tracking and diagnostic data to MongoDB.

editor

string

null

Designates an editor to use within the mongosh console. Overrides the EDITOR environment variable if set.

forceDisableTelemetry

boolean

false

Only available in the global configuration file. When true, users cannot enable telemetry manually.

historyLength

integer

1000

The number of items to store in mongosh REPL's history file.

inspectCompact

integer or boolean

3

The level of inner elements that mongosh outputs on a single line. Short array elements are also grouped together on a single line.

If set to false, mongosh outputs each field on its own line.

inspectDepth

integer or Infinity

6

The depth to which objects are printed. Setting inspectDepth to Infinity (the javascript object) prints all nested objects to their full depth.

logCompressionEnabled

boolean

false

Specifies whether MongoDB Shell compresses log files. When this value is true, MongoDB Shell uses gzip to compress logs. See Enable Log Compression.

logLocation

string

Depends on your operating system. See View Shell Logs.

Directory where MongoDB Shell writes log files. Specify an absolute filepath. See Specify Log File Location.

logMaxFileCount

integer or Infinity

100

Maximum number of log files that the MongoDB Shell retains. After the MongoDB Shell reaches the maximum log file count, it starts deleting the oldest log files until the count is below the threshold. See Modify Maximum Log File Count.

logRetentionDays

integer or Infinity

30

Number of days that MongoDB Shell log files are retained. If this value is set to Infinity, log files are not deleted based on age. To prevent log storage from growing too large, always specify at least one log retention criterion. See Log Retention.

logRetentionGB

float or Infinity

Unset

Maximum amount of space in gigabytes used for MongoDB Shell logs. If the combined size of MongoDB Shell logs exceeds this value, log files are deleted starting with the oldest logs.

If this value is set to Infinity, log files are not deleted based on storage size. To prevent log storage from growing too large, always specify at least one log retention criterion. See Log Retention.

redactHistory

string

remove

Controls what information is recorded in the shell history. Must be one of:

  • keep: Retain all history.

  • remove: Remove lines which contain sensitive information.

  • remove-redact: Redact sensitive information.

showStackTraces

boolean

false

Controls display of a stack trace along with error messages.

snippetAutoload

boolean

true

If true, automatically load installed snippets at startup.

snippetIndexSourceURLs

string

MongoDB Repository

A semicolon-separated list of URLs that link to a snippet registry.

snippetRegistryURL

string

The npm registry used by the mongosh npm client that installs snippet.

To configure mongosh settings, you can either use:

Back

Use an Editor