|
| 1 | +.. _mongosh-log-retention-gb: |
| 2 | + |
| 3 | +=============================== |
| 4 | +Modify Maximum Log Storage Size |
| 5 | +=============================== |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 1 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +You can specify a maximum combined storage size for |mdb-shell| log |
| 14 | +files. If the total size of all log files exceeds the maximum, log files |
| 15 | +are deleted until the combined size is below the threshold, starting |
| 16 | +with the oldest log files. By default, there is no maximum log storage |
| 17 | +size. |
| 18 | + |
| 19 | +About this Task |
| 20 | +--------------- |
| 21 | + |
| 22 | +To specify a maximum log storage size, set the ``logRetentionGB`` |
| 23 | +configuration option. ``logRetentionGB`` can be any positive float |
| 24 | +value (including less than ``1``). |
| 25 | + |
| 26 | +.. include:: /includes/log-retention-multiple-criteria.rst |
| 27 | + |
| 28 | +To check the current storage size of log files, check the size of the |
| 29 | +log folder. To see the current log folder, run the following command |
| 30 | +from the |mdb-shell|: |
| 31 | + |
| 32 | +.. code-block:: javascript |
| 33 | + |
| 34 | + config.get('logLocation') |
| 35 | + |
| 36 | +Before you Begin |
| 37 | +---------------- |
| 38 | + |
| 39 | +To check the current maximum log storage size, run the following |
| 40 | +command: |
| 41 | + |
| 42 | +.. code-block:: javascript |
| 43 | + |
| 44 | + config.get("logRetentionGB") |
| 45 | + |
| 46 | +Steps |
| 47 | +----- |
| 48 | + |
| 49 | +To modify maximum log storage size, set the ``logRetentionGB`` |
| 50 | +configuration option. You can set configuration options in the |
| 51 | +:ref:`configuration API <configure-settings-api>` or a |
| 52 | +:ref:`configuration file <configure-settings-global>`. |
| 53 | + |
| 54 | +Modify Maximum Log Storage Size with the API |
| 55 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 56 | + |
| 57 | +The following command uses the config API to set the maximum log storage |
| 58 | +size to 3.5 GB: |
| 59 | + |
| 60 | +.. io-code-block:: |
| 61 | + :copyable: true |
| 62 | + |
| 63 | + .. input:: |
| 64 | + :language: javascript |
| 65 | + |
| 66 | + config.set("logRetentionGB", 3.5) |
| 67 | + |
| 68 | + .. output:: |
| 69 | + :language: javascript |
| 70 | + |
| 71 | + Setting "logRetentionGB" has been changed |
| 72 | + |
| 73 | +Modify Maximum Log Storage Size with a Configuration File |
| 74 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 75 | + |
| 76 | +The following configuration file sets the maximum log storage size to |
| 77 | +3.5 GB: |
| 78 | + |
| 79 | +.. code-block:: yaml |
| 80 | + |
| 81 | + mongosh: |
| 82 | + logRetentionGB: 3.5 |
| 83 | + |
| 84 | +Disable Maximum Log Storage Size |
| 85 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 86 | + |
| 87 | +To instruct the |mdb-shell| to not delete logs based on storage size, |
| 88 | +set ``logRetentionGB`` to ``Infinity``. You can perform this action |
| 89 | +through the config API or configuration file. For example: |
| 90 | + |
| 91 | +.. code-block:: javascript |
| 92 | + |
| 93 | + config.set("logRetentionGB", Infinity) |
| 94 | + |
| 95 | +.. include:: /includes/specify-one-retention-criterion.rst |
0 commit comments