Skip to content

Commit 3b51c8b

Browse files
Document logging configuration settings (#4139)
1 parent 5c29127 commit 3b51c8b

File tree

26 files changed

+657
-117
lines changed

26 files changed

+657
-117
lines changed

doc/book/admin/logs.rst

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Logs
44
====
55

6-
Each Tarantool instance logs important events to its own log file ``<instance-name>.log``.
6+
Each Tarantool instance logs important events to its own log file.
77
For instances started with :ref:`tt <tt-cli>`, the log location is defined by
88
the ``log_dir`` parameter in the :ref:`tt configuration <tt-config>`.
99
By default, it's ``/var/log/tarantool`` in the ``tt`` :ref:`system mode <tt-config_modes>`,
@@ -14,34 +14,36 @@ To check how logging works, write something to the log using the :ref:`log <log-
1414

1515
.. code-block:: console
1616
17-
$ tt connect my_app
17+
$ tt connect application
1818
• Connecting to the instance...
19-
• Connected to /var/run/tarantool/my_app.control
19+
• Connected to application
2020
21-
/var/run/tarantool/my_app.control> require('log').info("Hello for the manual readers")
21+
application> require('log').info("Hello for the manual readers")
22+
---
23+
...
2224
2325
Then check the logs:
2426

2527
.. code-block:: console
2628
27-
$ tail /var/log/tarantool/my_app.log
28-
2023-09-12 18:13:00.396 [67173] main/111/guard of feedback_daemon/box.feedback_daemon V> metrics_collector restarted
29-
2023-09-12 18:13:00.396 [67173] main/103/-/box.feedback_daemon V> feedback_daemon started
30-
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(14) = 0x1090077b4
31-
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(26) = 0x1090077ec
32-
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(39) = 0x109007824
33-
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(24) = 0x10900785c
34-
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(39) = 0x109007894
35-
2023-09-12 18:13:00.396 [67173] main/106/checkpoint_daemon I> scheduled next checkpoint for Tue Sep 12 19:44:34 2023
36-
2023-09-12 18:13:00.396 [67173] main I> entering the event loop
37-
2023-09-12 18:13:11.656 [67173] main/114/console/unix/:/tarantool I> Hello for the manual readers
29+
$ tail instances.enabled/application/var/log/instance001/tt.log
30+
2024-04-09 17:34:29.489 [49502] main/106/gc I> wal/engine cleanup is resumed
31+
2024-04-09 17:34:29.489 [49502] main/104/interactive/box.load_cfg I> set 'instance_name' configuration option to "instance001"
32+
2024-04-09 17:34:29.489 [49502] main/104/interactive/box.load_cfg I> set 'custom_proc_title' configuration option to "tarantool - instance001"
33+
2024-04-09 17:34:29.489 [49502] main/104/interactive/box.load_cfg I> set 'log_nonblock' configuration option to false
34+
2024-04-09 17:34:29.489 [49502] main/104/interactive/box.load_cfg I> set 'replicaset_name' configuration option to "replicaset001"
35+
2024-04-09 17:34:29.489 [49502] main/104/interactive/box.load_cfg I> set 'listen' configuration option to [{"uri":"127.0.0.1:3301"}]
36+
2024-04-09 17:34:29.489 [49502] main/107/checkpoint_daemon I> scheduled next checkpoint for Tue Apr 9 19:08:04 2024
37+
2024-04-09 17:34:29.489 [49502] main/104/interactive/box.load_cfg I> set 'metrics' configuration option to {"labels":{"alias":"instance001"},"include":["all"],"exclude":[]}
38+
2024-04-09 17:34:29.489 [49502] main I> entering the event loop
39+
2024-04-09 17:34:38.905 [49502] main/116/console/unix/:/tarantool I> Hello for the manual readers
3840
3941
.. _admin-logs-rotation:
4042

4143
Log rotation
4244
------------
4345

44-
When :ref:`logging to a file <cfg_logging-log>`, the system administrator must ensure
46+
When :ref:`logging to a file <configuration_reference_log_file>`, the system administrator must ensure
4547
logs are rotated timely and do not take up all the available disk space.
4648
The recommended way to prevent log files from growing infinitely is using an external
4749
log rotation program, for example, ``logrotate``, which is pre-installed on most
@@ -76,22 +78,16 @@ To learn about log rotation in the deprecated ``tarantoolctl`` utility,
7678
check its :ref:`documentation <tarantoolctl-log-rotation>`.
7779

7880

79-
.. _admin-logs-formats:
81+
.. _admin-logs-destination:
8082

81-
Log formats
82-
-----------
83+
Log destination
84+
---------------
8385

84-
Tarantool can write its logs to a log file, to ``syslog``, or to a specified program
85-
through a pipe.
86+
Tarantool can write its logs to a log file, to ``syslog``, or to a specified program through a pipe.
87+
For example, to send logs to ``syslog``, specify the :ref:`log.to <configuration_reference_log_to>` parameter as follows:
8688

87-
File is the default log format for ``tt``. To send logs to a pipe or ``syslog``,
88-
specify the :ref:`box.cfg.log <cfg_logging-log>` parameter, for example:
89-
90-
.. code-block:: lua
91-
92-
box.cfg{log = '| cronolog tarantool.log'}
93-
-- or
94-
box.cfg{log = 'syslog:identity=tarantool,facility=user'}
95-
96-
In such configurations, log rotation is usually handled by the external program
97-
used for logging.
89+
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/log_syslog/config.yaml
90+
:language: yaml
91+
:start-at: log:
92+
:end-at: 127.0.0.1:514
93+
:dedent:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
audit_log:
22
to: pipe
3-
pipe: '| cronolog audit_tarantool.log'
3+
pipe: 'cronolog audit_tarantool.log'
44

55
groups:
66
group001:
@@ -10,4 +10,4 @@ groups:
1010
instance001:
1111
iproto:
1212
listen:
13-
- uri: '127.0.0.1:3301'
13+
- uri: '127.0.0.1:3301'

doc/code_snippets/snippets/config/instances.enabled/audit_log_syslog/config.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@ audit_log:
44
server: 'unix:/dev/log'
55
facility: 'user'
66
identity: 'tarantool_audit'
7-
filter: 'audit,auth,priv,password_change,access_denied'
7+
filter: [ audit, auth, priv, password_change, access_denied ]
88
extract_key: false
99

1010
groups:
1111
group001:
12-
iproto:
13-
listen:
14-
- uri: '127.0.0.1:3301'
1512
replicasets:
1613
replicaset001:
1714
instances:
1815
instance001:
1916
iproto:
2017
listen:
21-
- uri: '127.0.0.1:3301'
18+
- uri: '127.0.0.1:3301'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ffi = require('ffi')
2+
3+
-- Prints 'info' messages --
4+
ffi.C._say(ffi.C.S_INFO, nil, 0, nil, 'Info message from C module')
5+
--[[
6+
[6024] main/103/interactive I> Info message from C module
7+
---
8+
...
9+
--]]
10+
11+
-- Swallows 'debug' messages --
12+
ffi.C._say(ffi.C.S_DEBUG, nil, 0, nil, 'Debug message from C module')
13+
--[[
14+
---
15+
...
16+
--]]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
log:
2+
modules:
3+
tarantool: 'info'
4+
app:
5+
file: 'app.lua'
6+
7+
groups:
8+
group001:
9+
replicasets:
10+
replicaset001:
11+
instances:
12+
instance001:
13+
iproto:
14+
listen:
15+
- uri: '127.0.0.1:3301'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module1 = require('test.module1')
2+
module2 = require('test.module2')
3+
4+
-- Prints 'info' messages --
5+
module1.say_hello()
6+
--[[
7+
[92617] main/103/interactive/test.logging.module1 I> Info message from module1
8+
---
9+
...
10+
--]]
11+
12+
-- Swallows 'info' messages --
13+
module2.say_hello()
14+
--[[
15+
---
16+
...
17+
--]]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
log:
2+
modules:
3+
test.module1: 'verbose'
4+
test.module2: 'error'
5+
app:
6+
file: 'app.lua'
7+
8+
groups:
9+
group001:
10+
replicasets:
11+
replicaset001:
12+
instances:
13+
instance001:
14+
iproto:
15+
listen:
16+
- uri: '127.0.0.1:3301'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
return {
2+
say_hello = function()
3+
local log = require('log')
4+
log.info('Info message from module1')
5+
end
6+
}

0 commit comments

Comments
 (0)