@@ -13,32 +13,31 @@ Rotate Log Files
13
13
Overview
14
14
--------
15
15
16
- When used with the ``--logpath`` option or :setting:`systemLog.path` setting,
17
- :binary:`~bin.mongod` and :binary:`~bin.mongos` instances report
18
- a live account of all activity and operations to a log file.
19
- When reporting activity data to a log file, by default, MongoDB only rotates logs
20
- in response to the :dbcommand:`logRotate` command, or when the
21
- :binary:`~bin.mongod` or :binary:`~bin.mongos` process receives a ``SIGUSR1``
22
- signal from the operating system.
16
+ When used with the ``--logpath`` option or :setting:`systemLog.path`
17
+ setting, :binary:`~bin.mongod` and :binary:`~bin.mongos` instances
18
+ report a live account of all activity and operations to a log file.
19
+ When reporting activity data to a log file, by default, MongoDB only
20
+ rotates logs in response to the :dbcommand:`logRotate` command, or when
21
+ the :binary:`~bin.mongod` or :binary:`~bin.mongos` process receives a
22
+ ``SIGUSR1`` signal from the operating system.
23
23
24
24
MongoDB's standard log rotation approach archives the current
25
25
log file and starts a new one. To do this, the :binary:`~bin.mongod` or
26
- :binary:`~bin.mongos` instance renames the current log file by appending a
27
- UTC timestamp to the filename, in :term:`ISODate` format. It then
26
+ :binary:`~bin.mongos` instance renames the current log file by appending
27
+ a UTC timestamp to the filename, in :term:`ISODate` format. It then
28
28
opens a new log file, closes the old log file, and sends all new log
29
29
entries to the new log file.
30
30
31
- You can also configure MongoDB to support the Linux/Unix
32
- logrotate utility
33
- by setting :setting:`systemLog.logRotate` or
31
+ You can also configure MongoDB to support the Linux/Unix ``logrotate``
32
+ utility by setting :setting:`systemLog.logRotate` or
34
33
``--logRotate`` to ``reopen``. With ``reopen``, :binary:`~bin.mongod`
35
34
or :binary:`~bin.mongos` closes the log file, and
36
35
then reopens a log file with the same name, expecting that another
37
36
process renamed the file prior to rotation.
38
37
39
38
Finally, you can configure :binary:`~bin.mongod` to send log data to the
40
- ``syslog`` using the :option:`--syslog <mongod --syslog>` option. In this case, you can
41
- take advantage of alternate logrotation tools.
39
+ ``syslog`` using the :option:`--syslog <mongod --syslog>` option. In
40
+ this case, you can take advantage of alternate log rotation tools.
42
41
43
42
.. seealso:: For information on logging, see the
44
43
:ref:`monitoring-standard-loggging` section.
@@ -50,8 +49,8 @@ By default, MongoDB uses the
50
49
``--logRotate rename`` behavior.
51
50
With ``rename``, :binary:`~bin.mongod` or
52
51
:binary:`~bin.mongos` renames the current log file by appending a UTC
53
- timestamp to the filename, opens a new log file, closes the old log file,
54
- and sends all new log entries to the new log file.
52
+ timestamp to the filename, opens a new log file, closes the old log
53
+ file, and sends all new log entries to the new log file.
55
54
56
55
.. include:: /includes/steps/log-rotate-rename.rst
57
56
@@ -66,8 +65,8 @@ the log file following the typical Linux/Unix log rotate behavior.
66
65
Syslog Log Rotation
67
66
-------------------
68
67
69
- With syslog log rotation, :binary:`~bin.mongod` sends log data to the syslog
70
- rather than writing it to a file.
68
+ With syslog log rotation, :binary:`~bin.mongod` sends log data to the
69
+ syslog rather than writing it to a file.
71
70
72
71
Starting in version 4.2, MongoDB includes the :ref:`component
73
72
<log-message-components>` in its log messages to ``syslog``.
@@ -78,8 +77,18 @@ Forcing a Log Rotation with ``SIGUSR1``
78
77
---------------------------------------
79
78
80
79
For Linux and Unix-based systems, you can use the ``SIGUSR1`` signal
81
- to rotate the logs for a single process, as in the following:
80
+ to rotate the logs for a single process.
81
+
82
+ For example, if a running :binary:`~bin.mongod` instance has a
83
+ process ID (PID) of ``2200``, the following command rotates the log
84
+ file for that instance on Linux:
82
85
83
86
.. code-block:: sh
84
87
85
- kill -SIGUSR1 <mongod process id>
88
+ kill -SIGUSR1 2200
89
+
90
+ Interaction with Audit Logs
91
+ ---------------------------
92
+
93
+ If :doc:`auditing </core/auditing>` is enabled, the
94
+ :dbcommand:`logRotate` command also rotates the audit log.
0 commit comments