@@ -13,32 +13,31 @@ Rotate Log Files
1313Overview
1414--------
1515
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.
2323
2424MongoDB's standard log rotation approach archives the current
2525log 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
2828opens a new log file, closes the old log file, and sends all new log
2929entries to the new log file.
3030
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
3433``--logRotate`` to ``reopen``. With ``reopen``, :binary:`~bin.mongod`
3534or :binary:`~bin.mongos` closes the log file, and
3635then reopens a log file with the same name, expecting that another
3736process renamed the file prior to rotation.
3837
3938Finally, 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.
4241
4342.. seealso:: For information on logging, see the
4443 :ref:`monitoring-standard-loggging` section.
@@ -50,8 +49,8 @@ By default, MongoDB uses the
5049``--logRotate rename`` behavior.
5150With ``rename``, :binary:`~bin.mongod` or
5251: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.
5554
5655.. include:: /includes/steps/log-rotate-rename.rst
5756
@@ -66,8 +65,8 @@ the log file following the typical Linux/Unix log rotate behavior.
6665Syslog Log Rotation
6766-------------------
6867
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.
7170
7271Starting in version 4.2, MongoDB includes the :ref:`component
7372<log-message-components>` in its log messages to ``syslog``.
@@ -78,8 +77,18 @@ Forcing a Log Rotation with ``SIGUSR1``
7877---------------------------------------
7978
8079For 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:
8285
8386.. code-block:: sh
8487
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