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

RETURN VALUE

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

FACILITIES AND LEVELS

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

EXAMPLES

296       logger System rebooted
297       logger -p local0.notice -t HOSTIDM -f /dev/idmc
298       logger -n loghost.example.com System rebooted
299

SEE ALSO

301       journalctl(1), syslog(3), systemd.journal-fields(7)
302

STANDARDS

304       The logger command is expected to be IEEE Std 1003.2  ("POSIX.2")  com‐
305       patible.
306

AVAILABILITY

308       The  logger  command is part of the util-linux package and is available
309       from Linux Kernel Archive ⟨https://www.kernel.org/pub/linux/utils/util-
310       linux/⟩.
311
312
313
314util-linux                       November 2015                       LOGGER(1)
Impressum