3 ***********************
4 Extended Logging Target
5 ***********************
7 After creating one or more extended logging targets with the
8 :clicmd:`log extended EXTLOGNAME` command, the target(s) must be configured
9 for the desired logging output.
11 Each extended log target supports emitting log messages in one of the following
14 - ``rfc5424`` - :rfc:`5424` - modern syslog with ISO 8601 timestamps, time zone and
15 structured data (key/value pairs) support
16 - ``rfc3164`` - :rfc:`3164` - legacy BSD syslog, timestamps with 1 second granularity
17 - ``local-syslog`` - same as :rfc:`3164`, but without the hostname field
18 - ``journald`` - systemd's `native journald protocol <https://systemd.io/JOURNAL_NATIVE_PROTOCOL/>`_.
19 This protocol also supports structured data (key/value pairs).
24 The output location is configured with the following subcommands:
26 .. clicmd:: destination none
28 Disable the target while retaining its remaining configuration.
30 .. clicmd:: destination syslog [supports-rfc5424]
32 Send log messages to the system's standard log destination
33 (``/dev/log``). This does not use the C library's ``syslog()`` function,
34 instead writing directly to ``/dev/log``.
36 On NetBSD and FreeBSD, the RFC5424 format is automatically used when
37 the OS version is recent enough (5.0 for NetBSD, 12.0 for FreeBSD).
38 Unfortunately, support for this format cannot be autodetected otherwise,
39 and particularly on Linux systems must be enabled manually.
41 .. clicmd:: destination journald
43 Send log messages to systemd's journald.
45 .. clicmd:: destination <stdout|stderr|fd <(0-63)|envvar WORD>> \
48 Send log messages to one of the daemon's file descriptors. The
49 ``fd (0-63)`` and ``fd envvar WORD`` variants are intended to work with
50 the shell's ``command 3>something`` and bash's
51 ``command {ENVVAR}>something`` I/O redirection specifiers.
53 Only file descriptors open at a daemon's startup time can be used for
54 this; accidental misuse of a file descriptor that has been opened by
55 FRR itself is prevented.
57 Using FIFOs with this option will work but is unsupported and can cause
58 daemons to hang or crash depending on reader behavior.
60 Format defaults to RFC5424 if none is specified.
64 When starting FRR daemons from custom shell scripts, make sure not
65 to leak / leave extraneous file descriptors open. FRR daemons do not
68 .. clicmd:: destination file PATH \
69 [create [{user WORD|group WORD|mode PERMS}]|no-create] \
72 Log to a regular file. File permissions can be specified when FRR creates
75 Format defaults to RFC5424 if none is specified.
79 FRR will never change permissions or ownership on an existing log file.
80 In many cases, FRR will also not have permissions to set user and group
83 .. clicmd:: destination unix PATH [format FORMAT]
85 Connect to a UNIX domain socket and send log messages there. This will
86 autodetect ``SOCK_STREAM``, ``SOCK_SEQPACKET`` and ``SOCK_DGRAM`` and
87 adjust behavior appropriately.
92 .. clicmd:: priority PRIORITY
94 Select minimum priority of messages to send to this target. Defaults to
97 .. clicmd:: facility FACILITY
99 Select syslog facility for messages on this target. Defaults to `daemon`.
100 The :clicmd:`log facility [FACILITY]` command does not affect extended
103 .. clicmd:: timestamp precision (0-9)
105 Set desired number of sub-second timestamp digits. This only has an effect
106 for RFC5424 and journald format targets; the RFC3164 and local-syslogd
107 formats do not support any sub-second digits.
109 .. clicmd:: timestamp local-time
111 Use the local system timezone for timestamps rather than UTC (the default.)
113 RFC5424 and journald formats include zone information (``Z`` or ``+-NN:NN``
114 suffix in ISO8601). RFC3164 and local-syslogd offer no way of identifying
115 the time zone used, care must be taken that this option and the receiver
116 are configured identically, or the timestamp is replaced at the receiver.
120 FRR includes a timestamp in journald messages, but journald always
121 provides its own timestamp.
123 .. clicmd:: structured-data <code-location|version|unique-id|error-category|format-args>
125 Select additional key/value data to be included for the RFC5424 and journald
126 formats. Refer to the next section for details.
128 ``unique-id`` and ``error-category`` are enabled by default.
132 Log messages can grow in size significantly when enabling additional
139 When using the RFC5424 or journald formats, FRR can provide additional metadata
140 for log messages as key/value pairs. The following information can be added
143 +--------------------+--------------------+--------------+------------------+---------------------------------------------+
144 | Switch | 5424 group | 5424 item(s) | journald field | Contents |
145 +====================+====================+==============+==================+=============================================+
146 | always active | ``location@50145`` | ``tid`` | ``TID`` | Thread ID |
147 +--------------------+--------------------+--------------+------------------+---------------------------------------------+
148 | always active | ``location@50145`` | ``instance`` | ``FRR_INSTANCE`` | Multi-instance number |
149 +--------------------+--------------------+--------------+------------------+---------------------------------------------+
150 | ``unique-id`` | ``location@50145`` | ``id`` | ``FRR_ID`` | ``XXXXX-XXXXX`` unique message identifier |
151 +--------------------+--------------------+--------------+------------------+---------------------------------------------+
152 | ``error-category`` | ``location@50145`` | ``ec`` | ``FRR_EC`` | Integer error category number |
153 +--------------------+--------------------+--------------+------------------+---------------------------------------------+
154 | ``code-location`` | ``location@50145`` | ``file`` | ``CODE_FILE`` | Source code file name |
155 +--------------------+--------------------+--------------+------------------+---------------------------------------------+
156 | ``code-location`` | ``location@50145`` | ``line`` | ``CODE_LINE`` | Source code line number |
157 +--------------------+--------------------+--------------+------------------+---------------------------------------------+
158 | ``code-location`` | ``location@50145`` | ``func`` | ``CODE_FUNC`` | Source code function name |
159 +--------------------+--------------------+--------------+------------------+---------------------------------------------+
160 | ``format-args`` | ``args@50145`` | ``argN`` | ``FRR_ARGn`` | Message printf format arguments (n = 1..16) |
161 +--------------------+--------------------+--------------+------------------+---------------------------------------------+
162 | ``version`` | ``origin`` | multiple | n/a | FRR version information (IETF format) |
163 +--------------------+--------------------+--------------+------------------+---------------------------------------------+
165 The information added by ``version`` is
166 ``[origin enterpriseId="50145" software="FRRouting" swVersion="..."]``
167 and is the same for all log messages. (Hence makes little sense to include in
168 most scenarios.) 50145 is the FRRouting IANA Enterprise Number.
170 Crashlogs / backtraces do not include any additional information since it
171 cannot safely be retrieved from a crash handler. However, all of the above
172 destinations will deliver crashlogs.
175 Restart and Reconfiguration caveats
176 -----------------------------------
178 FRR uses "add-delete" semantics when reconfiguring log targets of any type
179 (including both extended targets mentioned here as well as the global
180 :clicmd:`log stdout LEVEL` and :clicmd:`log syslog [LEVEL]` variants.) This
181 means that when changing logging configuration, log messages from threads
182 executing in parallel may be duplicated for a brief window of time.
184 For the ``unix``, ``syslog`` and ``journald`` extended destinations, messages
185 can be lost when the receiver is restarted without the use of socket
186 activation (i.e. keeping the receiver socket open.) FRR does not buffer
187 log messages for later delivery, meaning anything logged while the receiver
188 is unavailable is lost. Since systemd provides socket activation for
189 journald, no messages will be lost on the ``journald`` target.