|
| 1 | +.. _mongosh-log-file-count: |
| 2 | + |
| 3 | +============================= |
| 4 | +Modify Maximum Log File Count |
| 5 | +============================= |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 1 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +You can specify the maximum number of log files that the |mdb-shell| |
| 14 | +retains. After the |mdb-shell| reaches the maximum log file count, it |
| 15 | +starts deleting the oldest log files until the count is below the |
| 16 | +threshold. |
| 17 | + |
| 18 | +The |mdb-shell| stores one log file for each session. By default, the |
| 19 | +|mdb-shell| stores up to 100 log files. |
| 20 | + |
| 21 | +About this Task |
| 22 | +--------------- |
| 23 | + |
| 24 | +.. include:: /includes/log-retention-multiple-criteria.rst |
| 25 | + |
| 26 | +Before you Begin |
| 27 | +---------------- |
| 28 | + |
| 29 | +To check the current maximum log file count, run the following command: |
| 30 | + |
| 31 | +.. code-block:: javascript |
| 32 | + |
| 33 | + config.get("logMaxFileCount") |
| 34 | + |
| 35 | +Steps |
| 36 | +----- |
| 37 | + |
| 38 | +To modify the maximum log file count, set the ``logMaxFileCount`` |
| 39 | +configuration option. You can set configuration options in the |
| 40 | +:ref:`configuration API <configure-settings-api>` or a |
| 41 | +:ref:`configuration file <configure-settings-global>`. |
| 42 | + |
| 43 | +Modify Maximum Log File Count with the Configuration API |
| 44 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 45 | + |
| 46 | +The following command uses the config API to set the maximum log file |
| 47 | +count to 200: |
| 48 | + |
| 49 | +.. io-code-block:: |
| 50 | + :copyable: true |
| 51 | + |
| 52 | + .. input:: |
| 53 | + :language: javascript |
| 54 | + |
| 55 | + config.set("logMaxFileCount", 200) |
| 56 | + |
| 57 | + .. output:: |
| 58 | + :language: javascript |
| 59 | + |
| 60 | + Setting "logMaxFileCount" has been changed |
| 61 | + |
| 62 | +Modify Maximum Log File Count with a Configuration File |
| 63 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 64 | + |
| 65 | +The following configuration file sets the maximum log file count to 200: |
| 66 | + |
| 67 | +.. code-block:: yaml |
| 68 | + |
| 69 | + mongosh: |
| 70 | + logMaxFileCount: 200 |
| 71 | + |
| 72 | +Disable Maximum Log File Limit |
| 73 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 74 | + |
| 75 | +To disable the maximum log file limit, set ``logMaxFileCount`` to |
| 76 | +``Infinity``. You can perform this action through the config API or |
| 77 | +configuration file. For example: |
| 78 | + |
| 79 | +.. code-block:: javascript |
| 80 | + |
| 81 | + config.set("logMaxFileCount", Infinity) |
| 82 | + |
| 83 | +.. include:: /includes/specify-one-retention-criterion.rst |
0 commit comments