|
| 1 | +.. _mongosh-logs-disable: |
| 2 | + |
| 3 | +=============== |
| 4 | +Disable Logging |
| 5 | +=============== |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 1 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +To specify whether |mdb-shell| writes log messages, use the |
| 14 | +``disableLogging`` configuration option. Logging is enabled by default. |
| 15 | + |
| 16 | +About this Task |
| 17 | +--------------- |
| 18 | + |
| 19 | +When you toggle logging, the change affects the current |mdb-shell| |
| 20 | +session. You don't need to start a new session for the change to take |
| 21 | +effect. |
| 22 | + |
| 23 | +Before you Begin |
| 24 | +---------------- |
| 25 | + |
| 26 | +To check if logging is currently disabled, run the following command: |
| 27 | + |
| 28 | +.. code-block:: javascript |
| 29 | + |
| 30 | + config.get("disableLogging") |
| 31 | + |
| 32 | +- If the command returns ``true``, logging is disabled. |
| 33 | +- If the command returns ``false``, logging is enabled. |
| 34 | + |
| 35 | +Steps |
| 36 | +----- |
| 37 | + |
| 38 | +You can set the ``disableLogging`` configuration option with the |
| 39 | +:ref:`configuration API <configure-settings-api>` or a |
| 40 | +:ref:`configuration file <configure-settings-global>`. |
| 41 | + |
| 42 | +Disable Logging with the Configuration API |
| 43 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 44 | + |
| 45 | +The following command uses the config API to disable logging for |
| 46 | +|mdb-shell|: |
| 47 | + |
| 48 | +.. io-code-block:: |
| 49 | + :copyable: true |
| 50 | + |
| 51 | + .. input:: |
| 52 | + :language: javascript |
| 53 | + |
| 54 | + config.set("disableLogging", true) |
| 55 | + |
| 56 | + .. output:: |
| 57 | + :language: javascript |
| 58 | + |
| 59 | + Setting "disableLogging" has been changed |
| 60 | + |
| 61 | +Disable Logging with a Configuration File |
| 62 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 63 | + |
| 64 | +The following configuration file disables logging for |mdb-shell|: |
| 65 | + |
| 66 | +.. code-block:: yaml |
| 67 | + |
| 68 | + mongosh: |
| 69 | + disableLogging: true |
| 70 | + |
| 71 | +Re-Enable Logging |
| 72 | +~~~~~~~~~~~~~~~~~ |
| 73 | + |
| 74 | +To enable logging, set ``disableLogging`` to ``false``. You can perform |
| 75 | +this action through the config API or configuration file. |
0 commit comments