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

RETURN VALUE

249       The logger utility exits 0 on success, and >0 if an error occurs.
250

FACILITIES AND LEVELS

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

EXAMPLES

290       logger System rebooted
291       logger -p local0.notice -t HOSTIDM -f /dev/idmc
292       logger -n loghost.example.com System rebooted
293

SEE ALSO

295       journalctl(1), syslog(3), systemd.journal-fields(7)
296

STANDARDS

298       The  logger  command is expected to be IEEE Std 1003.2 ("POSIX.2") com‐
299       patible.
300

AVAILABILITY

302       The logger command is part of the util-linux package and  is  available
303       from Linux Kernel Archive ⟨https://www.kernel.org/pub/linux/utils/util-
304       linux/⟩.
305
306
307
308util-linux                       November 2015                       LOGGER(1)
Impressum