-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace tarantoolctl with tt (CE part) (#3706)
Resolves #3501 Also: fixes build warnings Co-authored-by: Kseniia Antonova <[email protected]> Co-authored-by: Andrey Aksenov <[email protected]>
- Loading branch information
1 parent
2824070
commit 41aaa14
Showing
47 changed files
with
600 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,92 @@ | ||
.. _admin-logs: | ||
|
||
================================================================================ | ||
Logs | ||
================================================================================ | ||
==== | ||
|
||
Tarantool logs important events to a file, e.g. ``/var/log/tarantool/my_app.log``. | ||
To build the log file path, ``tarantoolctl`` takes the instance name, prepends | ||
the instance directory and appends “.log” extension. | ||
Each Tarantool instance logs important events to its own log file ``<instance-name>.log``. | ||
For instances started with :ref:`tt <tt-cli>`, the log location is defined by | ||
the ``log_dir`` parameter in the :ref:`tt configuration <tt-config>`. | ||
By default, it's ``/var/log/tarantool`` in the ``tt`` :ref:`system mode <tt-config_modes>`, | ||
and the ``var/log/`` subdirectory of the ``tt`` working directory in the :ref:`local mode <tt-config_modes>`. | ||
In the specified location, ``tt`` creates separate directories for each instance's logs. | ||
|
||
Let’s write something to the log file: | ||
To check how logging works, write something to the log using the :ref:`log <log-module>` module: | ||
|
||
.. code-block:: console | ||
$ tarantoolctl enter my_app | ||
/bin/tarantoolctl: connected to unix/:/var/run/tarantool/my_app.control | ||
unix/:/var/run/tarantool/my_app.control> require('log').info("Hello for the manual readers") | ||
--- | ||
... | ||
$ tt connect my_app | ||
• Connecting to the instance... | ||
• Connected to /var/run/tarantool/my_app.control | ||
/var/run/tarantool/my_app.control> require('log').info("Hello for the manual readers") | ||
Then check the logs: | ||
|
||
.. code-block:: console | ||
$ tail /var/log/tarantool/my_app.log | ||
2017-04-04 15:54:04.977 [29255] main/101/tarantoolctl C> version 1.7.3-382-g68ef3f6a9 | ||
2017-04-04 15:54:04.977 [29255] main/101/tarantoolctl C> log level 5 | ||
2017-04-04 15:54:04.978 [29255] main/101/tarantoolctl I> mapping 134217728 bytes for tuple arena... | ||
2017-04-04 15:54:04.985 [29255] iproto/101/main I> binary: bound to [::1]:3301 | ||
2017-04-04 15:54:04.986 [29255] main/101/tarantoolctl I> recovery start | ||
2017-04-04 15:54:04.986 [29255] main/101/tarantoolctl I> recovering from `/var/lib/tarantool/my_app/00000000000000000000.snap' | ||
2017-04-04 15:54:04.988 [29255] main/101/tarantoolctl I> ready to accept requests | ||
2017-04-04 15:54:04.988 [29255] main/101/tarantoolctl I> set 'checkpoint_interval' configuration option to 3600 | ||
2017-04-04 15:54:04.988 [29255] main/101/my_app I> Run console at unix/:/var/run/tarantool/my_app.control | ||
2017-04-04 15:54:04.989 [29255] main/106/console/unix/:/var/ I> started | ||
2017-04-04 15:54:04.989 [29255] main C> entering the event loop | ||
2017-04-04 15:54:47.147 [29255] main/107/console/unix/: I> Hello for the manual readers | ||
2023-09-12 18:13:00.396 [67173] main/111/guard of feedback_daemon/box.feedback_daemon V> metrics_collector restarted | ||
2023-09-12 18:13:00.396 [67173] main/103/-/box.feedback_daemon V> feedback_daemon started | ||
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(14) = 0x1090077b4 | ||
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(26) = 0x1090077ec | ||
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(39) = 0x109007824 | ||
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(24) = 0x10900785c | ||
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(39) = 0x109007894 | ||
2023-09-12 18:13:00.396 [67173] main/106/checkpoint_daemon I> scheduled next checkpoint for Tue Sep 12 19:44:34 2023 | ||
2023-09-12 18:13:00.396 [67173] main I> entering the event loop | ||
2023-09-12 18:13:11.656 [67173] main/114/console/unix/:/tarantool I> Hello for the manual readers | ||
.. _admin-logs-rotation: | ||
|
||
Log rotation | ||
------------ | ||
|
||
When :ref:`logging to a file <cfg_logging-log>`, the system administrator must ensure logs are | ||
rotated timely and do not take up all the available disk space. With | ||
``tarantoolctl``, log rotation is pre-configured to use ``logrotate`` program, | ||
which you must have installed. | ||
|
||
File ``/etc/logrotate.d/tarantool`` is part of the standard Tarantool | ||
distribution, and you can modify it to change the default behavior. This is what | ||
this file is usually like: | ||
|
||
.. code-block:: text | ||
/var/log/tarantool/*.log { | ||
daily | ||
size 512k | ||
missingok | ||
rotate 10 | ||
compress | ||
delaycompress | ||
create 0640 tarantool adm | ||
postrotate | ||
/usr/bin/tarantoolctl logrotate `basename ${1%%.*}` | ||
endscript | ||
} | ||
If you use a different log rotation program, you can invoke | ||
``tarantoolctl logrotate`` command to request instances to reopen their log | ||
files after they were moved by the program of your choice. | ||
|
||
Tarantool can write its logs to a log file, ``syslog`` or a program specified | ||
in the configuration file (see :ref:`log <cfg_logging-log>` parameter). | ||
|
||
By default, logs are written to a file as defined in ``tarantoolctl`` | ||
defaults. ``tarantoolctl`` automatically detects if an instance is using | ||
``syslog`` or an external program for logging, and does not override the log | ||
destination in this case. In such configurations, log rotation is usually | ||
handled by the external program used for logging. So, | ||
``tarantoolctl logrotate`` command works only if logging-into-file is enabled | ||
in the instance file. | ||
rotated timely and do not take up all the available disk space. | ||
To prevent log files from growing infinitely, ``tt`` automatically rotates instance | ||
logs. The following ``tt`` configuration parameters define the log rotation: | ||
``log_maxsize`` (in megabytes) and ``log_maxage`` (in days). When any of these | ||
limits is reached, the log is rotated. | ||
Additionally, there is the ``log_maxbackups`` parameter (the number of stored log | ||
files for an instance), which enables automatic removal of old log files. | ||
|
||
.. code-block:: yaml | ||
# tt.yaml | ||
tt: | ||
app: | ||
log_maxsize: 100 | ||
log_maxage: 3 | ||
log_maxbackups: 50 | ||
# ... | ||
There is also the :ref:`tt logrotate <tt-logrotate>` command that performs log | ||
rotation on demand. | ||
|
||
.. code-block:: bash | ||
tt logrotate my_app | ||
To learn about log rotation in the deprecated ``tarantoolctl`` utility, | ||
check its :ref:`documentation <tarantoolctl-log-rotation>`. | ||
|
||
|
||
.. _admin-logs-formats: | ||
|
||
Log formats | ||
----------- | ||
|
||
Tarantool can write its logs to a log file, to ``syslog``, or to a specified program | ||
through a pipe. | ||
|
||
File is the default log format for ``tt``. To send logs to a pipe or ``syslog``, | ||
specify the :ref:`box.cfg.log <cfg_logging-log>` parameter, for example: | ||
|
||
.. code-block:: lua | ||
box.cfg{log = '| cronolog tarantool.log'} | ||
-- or | ||
box.cfg{log = 'syslog:identity=tarantool,facility=user'} | ||
In such configurations, log rotation is usually handled by the external program | ||
used for logging. |
Oops, something went wrong.