Skip to content

Commit 0ecf437

Browse files
DOCSP-47935-log-retention-duration (#384)
* DOCSP-47935-log-retention-duration * add duration page to toc * WIP * edit * edit * wording * edit * edit * edit * wording * retry build * wording
1 parent 1f4d559 commit 0ecf437

File tree

6 files changed

+126
-6
lines changed

6 files changed

+126
-6
lines changed

snooty.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ toc_landing_pages = ["/install",
1313
"/configure-mongosh",
1414
"/reference/configure-shell-settings",
1515
"/reference/ejson",
16-
"/logs"
16+
"/logs",
17+
"/logs/retention"
1718
]
1819

1920
[constants]

source/includes/list-table-shell-properties.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@
7171
- Directory where MongoDB Shell writes log files. Specify an
7272
absolute filepath. See :ref:`mongosh-log-location`.
7373

74+
* - ``logRetentionDays``
75+
- integer or Infinity
76+
- 30
77+
- Number of days that |mdb-shell| log files are retained. If this
78+
value is set to ``Infinity``, log files are not deleted based on
79+
age. To prevent log storage from growing too large, always
80+
specify at least one log retention criterion. See
81+
:ref:`mongosh-logs-retention`.
82+
7483
* - ``redactHistory``
7584
- string
7685
- ``remove``
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
You can specify multiple criteria for log retention. For example, you
2+
can specify a maximum duration for log files of 60 days and a maximum
3+
log storage size of 2GB. Logs are deleted when any retention criterion
4+
is met, starting with the oldest logs.

source/logs.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ history:
6363
Log Retention
6464
-------------
6565

66-
``mongosh`` retains up to 100 log files for 30 days. ``mongosh``
67-
automatically deletes log files older than 30 days.
66+
By default, ``mongosh`` retains up to 100 log files for 30 days.
67+
``mongosh`` automatically deletes log files older than 30 days. To
68+
customize log file retention, see :ref:`mongosh-logs-retention`.
6869

6970
.. toctree::
7071
:titlesonly:
7172

72-
Disable Logging </logs/disable>
73-
Specify Log Location <logs/location>
74-
Write Custom Log Entries <logs/custom-entries>
73+
Specify Log Location </logs/location>
74+
Write Custom Log Entries </logs/custom-entries>
75+
Retention </logs/retention>
7576
Enable Log Compression </logs/compression>
77+
Disable Logging </logs/disable>

source/logs/retention.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.. _mongosh-logs-retention:
2+
3+
=============
4+
Log Retention
5+
=============
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
You can customize how |mdb-shell| logs are retained. By default, the
14+
system retains 100 log files for 30 days. You can choose to retain logs
15+
based on a combination of time, storage size, and number of log files.
16+
17+
Get Started
18+
-----------
19+
20+
To customize log retention, see these pages:
21+
22+
- :ref:`mongosh-log-file-duration`
23+
24+
Details
25+
-------
26+
27+
.. include:: /includes/log-retention-multiple-criteria.rst
28+
29+
.. toctree::
30+
:titlesonly:
31+
32+
Duration </logs/retention/duration>

source/logs/retention/duration.txt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
.. _mongosh-log-file-duration:
2+
3+
=============================
4+
Modify Log Retention Duration
5+
=============================
6+
7+
You can modify how long |mdb-shell| log files are retained. A log
8+
cleanup process automatically deletes log files older than the specified
9+
retention period. By default, log files are retained for 30 days.
10+
11+
About this Task
12+
---------------
13+
14+
.. include:: /includes/log-retention-multiple-criteria.rst
15+
16+
Before you Begin
17+
----------------
18+
19+
To check the current log retention duration, run the following command:
20+
21+
.. code-block:: javascript
22+
23+
config.get("logRetentionDays")
24+
25+
Steps
26+
-----
27+
28+
To modify how long log files are retained, set the ``logRetentionDays``
29+
configuration option. You can set configuration options in the
30+
configuration API or a configuration file.
31+
32+
Modify Log Duration with the Configuration API
33+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34+
35+
The following command uses the config API to set log retention to 60
36+
days:
37+
38+
.. io-code-block::
39+
:copyable: true
40+
41+
.. input::
42+
:language: javascript
43+
44+
config.set("logRetentionDays", 60)
45+
46+
.. output::
47+
:language: javascript
48+
49+
Setting "logRetentionDays" has been changed
50+
51+
Modify Log Duration with a Configuration File
52+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53+
54+
The following configuration file sets log retention to 60
55+
days:
56+
57+
.. code-block:: yaml
58+
59+
mongosh:
60+
logRetentionDays: 60
61+
62+
Disable Duration-Based Log Cleanup
63+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64+
65+
To instruct |mdb-shell| to not delete logs based on file age, set
66+
``logRetentionDays`` to ``Infinity``. You can perform this action
67+
through the config API or configuration file.
68+
69+
.. important::
70+
71+
To prevent log storage from growing too large, always specify at
72+
least one log retention criterion.

0 commit comments

Comments
 (0)