1LOGGER(1)                        User Commands                       LOGGER(1)
2
3
4

NAME

6       logger - enter messages into the system log
7

SYNOPSIS

9       logger [options] message
10

DESCRIPTION

12       logger makes entries in the system log.
13
14       When the optional message argument is present, it is written to the
15       log. If it is not present, and the -f option is not given either, then
16       standard input is logged.
17

OPTIONS

19       -d, --udp
20           Use datagrams (UDP) only. By default the connection is tried to the
21           syslog port defined in /etc/services, which is often 514.
22
23           See also --server and --socket to specify where to connect.
24
25       -e, --skip-empty
26           Ignore empty lines when processing files. An empty line is defined
27           to be a line without any characters. Thus a line consisting only of
28           whitespace is NOT considered empty. Note that when the
29           --prio-prefix option is specified, the priority is not part of the
30           line. Thus an empty line in this mode is a line that does not have
31           any characters after the priority prefix (e.g., <13>).
32
33       -f, --file file
34           Log the contents of the specified file. This option cannot be
35           combined with a command-line message.
36
37       -i
38           Log the PID of the logger process with each line.
39
40       --id[=id]
41           Log the PID of the logger process with each line. When the optional
42           argument id is specified, then it is used instead of the logger
43           command’s PID. The use of --id=$$ (PPID) is recommended in scripts
44           that send several messages.
45
46           Note that the system logging infrastructure (for example systemd
47           when listening on /dev/log) may follow local socket credentials to
48           overwrite the PID specified in the message. logger(1) is able to
49           set those socket credentials to the given id, but only if you have
50           root permissions and a process with the specified PID exists,
51           otherwise the socket credentials are not modified and the problem
52           is silently ignored.
53
54       --journald[=file]
55           Write a systemd journal entry. The entry is read from the given
56           file, when specified, otherwise from standard input. Each line must
57           begin with a field that is accepted by journald; see
58           systemd.journal-fields(7) for details. The use of a MESSAGE_ID
59           field is generally a good idea, as it makes finding entries easy.
60           Examples:
61
62                  logger --journald <<end
63                  MESSAGE_ID=67feb6ffbaf24c5cbec13c008dd72309
64                  MESSAGE=The dogs bark, but the caravan goes on.
65                  DOGS=bark
66                  CARAVAN=goes on
67                  end
68
69                  logger --journald=entry.txt
70
71           Notice that --journald will ignore values of other options, such as
72           priority. If priority is needed it must be within input, and use
73           PRIORITY field. The simple execution of journalctl(1) will display
74           MESSAGE field. Use journalctl --output json-pretty to see rest of
75           the fields.
76
77           To include newlines in MESSAGE, specify MESSAGE several times. This
78           is handled as a special case, other fields will be stored as an
79           array in the journal if they appear multiple times.
80
81       --msgid msgid
82           Sets the RFC 5424 <https://tools.ietf.org/html/rfc5424> MSGID
83           field. Note that the space character is not permitted inside of
84           msgid. This option is only used if --rfc5424 is specified as well;
85           otherwise, it is silently ignored.
86
87       -n, --server server
88           Write to the specified remote syslog server instead of to the
89           system log socket. Unless --udp or --tcp is specified, logger will
90           first try to use UDP, but if this fails a TCP connection is
91           attempted.
92
93       --no-act
94           Causes everything to be done except for writing the log message to
95           the system log, and removing the connection to the journal. This
96           option can be used together with --stderr for testing purposes.
97
98       --octet-count
99           Use the RFC 6587 <https://tools.ietf.org/html/rfc6587> octet
100           counting framing method for sending messages. When this option is
101           not used, the default is no framing on UDP, and RFC6587
102           non-transparent framing (also known as octet stuffing) on TCP.
103
104       -P, --port port
105           Use the specified port. When this option is not specified, the port
106           defaults to syslog for udp and to syslog-conn for tcp connections.
107
108       -p, --priority priority
109           Enter the message into the log with the specified priority. The
110           priority may be specified numerically or as a facility.level pair.
111           For example, -p local3.info logs the message as informational in
112           the local3 facility. The default is user.notice.
113
114       --prio-prefix
115           Look for a syslog prefix on every line read from standard input.
116           This prefix is a decimal number within angle brackets that encodes
117           both the facility and the level. The number is constructed by
118           multiplying the facility by 8 and then adding the level. For
119           example, local0.info, meaning facility=16 and level=6, becomes
120           <134>.
121
122           If the prefix contains no facility, the facility defaults to what
123           is specified by the -p option. Similarly, if no prefix is provided,
124           the line is logged using the priority given with -p.
125
126           This option doesn’t affect a command-line message.
127
128       --rfc3164
129           Use the RFC 3164 <https://tools.ietf.org/html/rfc3164> BSD syslog
130           protocol to submit messages to a remote server.
131
132       --rfc5424[=without]
133           Use the RFC 5424 <https://tools.ietf.org/html/rfc5424> syslog
134           protocol to submit messages to a remote server. The optional
135           without argument can be a comma-separated list of the following
136           values: notq, notime, nohost.
137
138           The notq value suppresses the time-quality structured data from the
139           submitted message. The time-quality information shows whether the
140           local clock was synchronized plus the maximum number of
141           microseconds the timestamp might be off. The time quality is also
142           automatically suppressed when --sd-id timeQuality is specified.
143
144           The notime value (which implies notq) suppresses the complete
145           sender timestamp that is in ISO-8601 format, including microseconds
146           and timezone.
147
148           The nohost value suppresses gethostname(2) information from the
149           message header.
150
151           The RFC 5424 protocol has been the default for logger since version
152           2.26.
153
154       -s, --stderr
155           Output the message to standard error as well as to the system log.
156
157       --sd-id name[@digits]
158           Specifies a structured data element ID for an RFC 5424 message
159           header. The option has to be used before --sd-param to introduce a
160           new element. The number of structured data elements is unlimited.
161           The ID (name plus possibly @digits) is case-sensitive and uniquely
162           identifies the type and purpose of the element. The same ID must
163           not exist more than once in a message. The @digits part is required
164           for user-defined non-standardized IDs.
165
166           logger currently generates the timeQuality standardized element
167           only. RFC 5424 also describes the elements origin (with parameters
168           ip, enterpriseId, software and swVersion) and meta (with parameters
169           sequenceId, sysUpTime and language). These element IDs may be
170           specified without the @digits suffix.
171
172       --sd-param name=value
173           Specifies a structured data element parameter, a name and value
174           pair. The option has to be used after --sd-id and may be specified
175           more than once for the same element. Note that the quotation marks
176           around value are required and must be escaped on the command line.
177
178                   logger --rfc5424 --sd-id zoo@123             \
179                                    --sd-param tiger="hungry"   \
180                                    --sd-param zebra="running"  \
181                                    --sd-id manager@123         \
182                                    --sd-param onMeeting="yes"  \
183                                    "this is message"
184
185           produces:
186
187           <13>1 2015-10-01T14:07:59.168662+02:00 ws kzak - - [timeQuality
188           tzKnown="1" isSynced="1" syncAccuracy="218616"][zoo@123
189           tiger="hungry" zebra="running"][manager@123 onMeeting="yes"] this
190           is message
191
192       -S, --size size
193           Sets the maximum permitted message size to size. The default is
194           1KiB characters, which is the limit traditionally used and
195           specified in RFC 3164. With RFC 5424, this limit has become
196           flexible. A good assumption is that RFC 5424 receivers can at least
197           process 4KiB messages.
198
199           Most receivers accept messages larger than 1KiB over any type of
200           syslog protocol. As such, the --size option affects logger in all
201           cases (not only when --rfc5424 was used).
202
203           Note: the message-size limit limits the overall message size,
204           including the syslog header. Header sizes vary depending on the
205           selected options and the hostname length. As a rule of thumb,
206           headers are usually not longer than 50 to 80 characters. When
207           selecting a maximum message size, it is important to ensure that
208           the receiver supports the max size as well, otherwise messages may
209           become truncated. Again, as a rule of thumb two to four KiB message
210           size should generally be OK, whereas anything larger should be
211           verified to work.
212
213       --socket-errors[=mode]
214           Print errors about Unix socket connections. The mode can be a value
215           of off, on, or auto. When the mode is auto, then logger will detect
216           if the init process is systemd(1), and if so assumption is made
217           /dev/log can be used early at boot. Other init systems lack of
218           /dev/log will not cause errors that is identical with messaging
219           using openlog(3) system call. The logger(1) before version 2.26
220           used openlog(3), and hence was unable to detected loss of messages
221           sent to Unix sockets.
222
223           The default mode is auto. When errors are not enabled lost messages
224           are not communicated and will result to successful exit status of
225           logger(1) invocation.
226
227       -T, --tcp
228           Use stream (TCP) only. By default the connection is tried to the
229           syslog-conn port defined in /etc/services, which is often 601.
230
231           See also --server and --socket to specify where to connect.
232
233       -t, --tag tag
234           Mark every line to be logged with the specified tag. The default
235           tag is the name of the user logged in on the terminal (or a user
236           name based on effective user ID).
237
238       -u, --socket socket
239           Write to the specified socket instead of to the system log socket.
240
241       --
242           End the argument list. This allows the message to start with a
243           hyphen (-).
244
245       -h, --help
246           Display help text and exit.
247
248       -V, --version
249           Print version and exit.
250

EXIT STATUS

252       The logger utility exits 0 on success, and >0 if an error occurs.
253

FACILITIES AND LEVELS

255       Valid facility names are:
256
257       auth
258       authpriv for security information of a sensitive nature
259       cron
260
261       daemon
262       ftp
263       kern cannot be generated from userspace process, automatically
264       converted to user
265
266       lpr
267       mail
268       news
269       syslog
270       user
271       uucp
272       local0
273       to
274       local7
275       security deprecated synonym for auth
276
277       Valid level names are:
278
279       emerg
280       alert
281       crit
282       err
283       warning
284       notice
285       info
286       debug
287       panic deprecated synonym for emerg
288       error deprecated synonym for err
289       warn deprecated synonym for warning
290
291       For the priority order and intended purposes of these facilities and
292       levels, see syslog(3).
293

CONFORMING TO

295       The logger command is expected to be IEEE Std 1003.2 ("POSIX.2")
296       compatible.
297

EXAMPLES

299          logger System rebooted
300
301          logger -p local0.notice -t HOSTIDM -f /dev/idmc
302
303          logger -n loghost.example.com System rebooted
304

AUTHORS

306       The logger command was originally written by University of California
307       in 1983-1993 and later rewritten by Karel Zak <kzak@redhat.com>, Rainer
308       Gerhards <rgerhards@adiscon.com>, and Sami Kerola <kerolasa@iki.fi>.
309

SEE ALSO

311       journalctl(1), syslog(3), systemd.journal-fields(7)
312

REPORTING BUGS

314       For bug reports, use the issue tracker at
315       https://github.com/util-linux/util-linux/issues.
316

AVAILABILITY

318       The logger command is part of the util-linux package which can be
319       downloaded from Linux Kernel Archive
320       <https://www.kernel.org/pub/linux/utils/util-linux/>.
321
322
323
324util-linux 2.39.2                 2023-06-14                         LOGGER(1)
Impressum