diff --git a/source/includes/list-table-shell-properties.rst b/source/includes/list-table-shell-properties.rst index 522b7ca8..1b2b4a27 100644 --- a/source/includes/list-table-shell-properties.rst +++ b/source/includes/list-table-shell-properties.rst @@ -88,6 +88,18 @@ specify at least one log retention criterion. See :ref:`mongosh-logs-retention`. + * - ``logRetentionGB`` + - float or Infinity + - Unset + - Maximum amount of space in gigabytes used for |mdb-shell| logs. + If the combined size of |mdb-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 + :ref:`mongosh-logs-retention`. + * - ``redactHistory`` - string - ``remove`` diff --git a/source/logs/retention.txt b/source/logs/retention.txt index 6d294185..942592b9 100644 --- a/source/logs/retention.txt +++ b/source/logs/retention.txt @@ -20,6 +20,7 @@ Get Started To customize log retention, see these pages: - :ref:`mongosh-log-file-duration` +- :ref:`mongosh-log-retention-gb` - :ref:`mongosh-log-file-count` Details @@ -31,4 +32,5 @@ Details :titlesonly: Duration + Storage Size File Count diff --git a/source/logs/retention/duration.txt b/source/logs/retention/duration.txt index 00c4be6b..76679f5a 100644 --- a/source/logs/retention/duration.txt +++ b/source/logs/retention/duration.txt @@ -4,6 +4,12 @@ Modify Log Retention Duration ============================= +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + You can modify how long |mdb-shell| log files are retained. A log cleanup process automatically deletes log files older than the specified retention period. By default, log files are retained for 30 days. @@ -64,9 +70,10 @@ Disable Duration-Based Log Cleanup To instruct |mdb-shell| to not delete logs based on file age, set ``logRetentionDays`` to ``Infinity``. You can perform this action -through the config API or configuration file. +through the config API or configuration file. For example: + +.. code-block:: javascript -.. important:: + config.set("logRetentionDays", Infinity) - To prevent log storage from growing too large, always specify at - least one log retention criterion. +.. include:: /includes/specify-one-retention-criterion.rst diff --git a/source/logs/retention/size.txt b/source/logs/retention/size.txt new file mode 100644 index 00000000..b46185ef --- /dev/null +++ b/source/logs/retention/size.txt @@ -0,0 +1,95 @@ +.. _mongosh-log-retention-gb: + +=============================== +Modify Maximum Log Storage Size +=============================== + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +You can specify a maximum combined storage size for |mdb-shell| log +files. If the total size of all log files exceeds the maximum, log files +are deleted until the combined size is below the threshold, starting +with the oldest log files. By default, there is no maximum log storage +size. + +About this Task +--------------- + +To specify a maximum log storage size, set the ``logRetentionGB`` +configuration option. ``logRetentionGB`` can be any positive float +value (including less than ``1``). + +.. include:: /includes/log-retention-multiple-criteria.rst + +To check the current storage size of log files, check the size of the +log folder. To see the current log folder, run the following command +from the |mdb-shell|: + +.. code-block:: javascript + + config.get('logLocation') + +Before you Begin +---------------- + +To check the current maximum log storage size, run the following +command: + +.. code-block:: javascript + + config.get("logRetentionGB") + +Steps +----- + +To modify maximum log storage size, set the ``logRetentionGB`` +configuration option. You can set configuration options in the +:ref:`configuration API ` or a +:ref:`configuration file `. + +Modify Maximum Log Storage Size with the API +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following command uses the config API to set the maximum log storage +size to 3.5 GB: + +.. io-code-block:: + :copyable: true + + .. input:: + :language: javascript + + config.set("logRetentionGB", 3.5) + + .. output:: + :language: javascript + + Setting "logRetentionGB" has been changed + +Modify Maximum Log Storage Size with a Configuration File +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following configuration file sets the maximum log storage size to +3.5 GB: + +.. code-block:: yaml + + mongosh: + logRetentionGB: 3.5 + +Disable Maximum Log Storage Size +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To instruct the |mdb-shell| to not delete logs based on storage size, +set ``logRetentionGB`` to ``Infinity``. You can perform this action +through the config API or configuration file. For example: + +.. code-block:: javascript + + config.set("logRetentionGB", Infinity) + +.. include:: /includes/specify-one-retention-criterion.rst