summaryrefslogtreecommitdiffstats
path: root/misc-utils/logger.1
blob: 3bfcb3dbbd5a05d5bbc9e33cf9b688f4efc63b5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
.\" Copyright (c) 1983, 1990, 1993
.\"	The Regents of the University of California.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"	This product includes software developed by the University of
.\"	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"	@(#)logger.1	8.1 (Berkeley) 6/6/93
.\"
.\" Section on valid facility and level strings added by
.\" and1000@debian.org, 26 Oct 1997.
.TH LOGGER "1" "June 2014" "util-linux" "User Commands"
.SH NAME
logger \- a shell command interface to the syslog(3) system log module
.SH SYNOPSIS
.B logger
.RI [ options "] [" message ]
.SH DESCRIPTION
.B logger
makes entries in the system log.  It provides a shell command
interface to the
.BR syslog (3)
system log module.
.SH OPTIONS
.TP
\fB\-d\fR, \fB\-\-udp\fR
Use datagram (UDP) only.  By default the connection is tried to the
.I syslog
port defined in /etc/services, which is often
.IR 514 .
.TP
\fB\-h\fR, \fB\-\-help\fR
Display help text and exit.
.TP
\fB\-i\fR, \fB\-\-id\fR[=\fBid\fR]
Log the PID of the logger process with each line.  When optional
argument
.B id
is specified then it is used instead of logger command PID.  Use of
.B --id=$$
(PPID) is recommended in scripts that send several messages.
.TP
\fB\-n\fR, \fB\-\-server\fR \fIserver\fR
Write to the specified remote syslog
.I server
instead of to the builtin syslog routines.  Unless
.B \-\-udp
or
.B \-\-tcp
is specified, \fBlogger\fR will first try to use UDP,
but if thist fails a TCP connection is attempted.
.TP
\fB\-P\fR, \fB\-\-port\fR \fIport\fR
Use the specified
.IR port .
When
.I port
is not specified it defaults to
.I syslog
for udp and
.I syslog-conn
for tcp connections.
.TP
\fB\-f\fR, \fB\-\-file\fR \fIfile\fR
Log the contents of the specified
.IR file .
This option cannot be combined with a command-line message.
.TP
\fB\-p\fR, \fB\-\-priority\fR \fIpriority\fR
Enter the message into the log with the specified
.IR priority  .
The priority may be specified numerically or as a
.I facility.level
pair.
For example,
.B -p
.I local3.info
logs the message as informational in the local3 facility.
The default is
.IR user.notice .
.TP
\fB\-\-prio\-prefix\fR
Look for a syslog prefix on every line read from standard input.
This prefix is a number within angle brackets that contains both the facility
and the level.  This decimal prefix is constructed by multiplying the
facility by 8 and then adding the level.  Thus, for example, \fIlocal0.info\fR,
facility=16 and level=6, becomes \fI<134>\fR.

If the prefix contains no facility, the facility defaults to what is
specified by the \fB\-p\fR option.  Similarly, if no prefix is provided,
the line is logged using the \fB\-p\fR \fIpriority\fR.

This option doesn't affect a command-line message.

.TP
\fB\-\-rfc3164\fR
Use RFC 3164 BSD syslog protocol to submit messages to remote server.
.TP
\fB\-\-rfc5424\fR [\fInotime\fR,\fInotq\fR,\fInohost\fR]
Use RFC 5424 syslog protocol to submit messages to remote server.
Optional argument
.I notime
will suppress submission of sender time stamp that is in ISO-8601 format,
including microseconds and timezone.  When
.I notime
is specified the time quality structured data, that can be suppressed
separately with
.IR notq ,
is excluded from output.  The time quality information tells if local
clock was syncronized, and maximum number of microseconds the time stamp
could be off.  Option argument
.I nohost
will suppress
.IR gethostname (2)
information from message header.
.IP
The rfc5424 protocol has been default for
.B logger
since version 2.26.
.TP
\fB\-s\fR, \fB\-\-stderr\fR
Output the message to standard error as well as to the system log.
.TP
\fB\-T\fR, \fB\-\-tcp\fR
Use stream (TCP) only.  By default the connection is tried to the
.I syslog-conn
port defined in /etc/services, which is often
.IR 601 .
.TP
\fB\-t\fR, \fB\-\-tag\fR \fItag\fR
Mark every line to be logged with the specified
.IR tag .
.TP
\fB\-u\fR, \fB\-\-socket\fR \fIsocket\fR
Write to the specified
.I socket
instead of to the builtin syslog routines.
.TP
\fB\-\-journald\fR [\fIfile\fR]
Write systemd journal entry.  The entry is read from
.I stdin
or input
.IR file .
Each new line must begin with a field that is accepted by journald, see
.IR systemd.journal-fields (7)
for details.  Use of MESSAGE_ID field is generally good idea, as they
make finding entries easy.
.IP
.nf
$ printf "%s\\n%s\\n%s\\n" MESSAGE_ID=86184c3b1aa444f58ebe7b30fec1438b DOGS=bark "CARAVAN=goes on" | logger --journald
$ logger --journald=entry.txt
.fi
.IP
Notice that
.B \-\-journald
will ignore values of other options, such as priority.  If priority is
needed it must be within input, and use PRIORITY field.  The simple
execution of
.B journalctl
will display MESSAGE field.  Use
.B journalctl --output json-pretty
to see rest of the fields.
.TP
\fB\-V\fR, \fB\-\-version\fR
Display version information and exit.
.TP
\fB\-\-\fR
End the argument list.  This is to allow the
.I message
to start with a hyphen (\-).
.TP
.I message
Write this \fImessage\fR to the log; if not specified, and the
.B \-f
flag is not provided, standard input is logged.
.SH RETURN VALUE
The
.B logger
utility exits 0 on success, and >0 if an error occurs.
.SH FACILITIES AND LEVELS
Valid facility names are:
.IP
.TS
tab(:);
left l l.
\fIauth\fR
\fIauthpriv\fR:for security information of a sensitive nature
\fIcron\fR
\fIdaemon\fR
\fIftp\fR
\fIkern\fR:cannot be generated from user process
\fIlpr\fR
\fImail\fR
\fInews\fR
\fIsyslog\fR
\fIuser\fR
\fIuucp\fR
\fIlocal0\fR
  to:
\fIlocal7\fR
\fIsecurity\fR:deprecated synonym for \fIauth\fR
.TE
.PP
Valid level names are:
.IP
.TS
tab(:);
left l l.
\fIemerg\fR
\fIalert\fR
\fIcrit\fR
\fIerr\fR
\fIwarning\fR
\fInotice\fR
\fIinfo\fR
\fIdebug\fR
\fIpanic\fR:deprecated synonym for \fIemerg\fR
\fIerror\fR:deprecated synonym for \fIerr\fR
\fIwarn\fR:deprecated synonym for \fIwarning\fR
.TE
.PP
For the priority order and intended purposes of these facilities and levels, see
.BR syslog (3).
.SH EXAMPLES
logger System rebooted
.br
logger \-p local0.notice \-t HOSTIDM \-f /dev/idmc
.br
logger \-n loghost.example.com System rebooted
.SH SEE ALSO
.BR syslog (3),
.BR syslogd (8),
.BR journalctl (1),
.BR systemd.journal-fields (7)
.SH STANDARDS
The
.B logger
command is expected to be IEEE Std 1003.2 ("POSIX.2") compatible.
.SH AVAILABILITY
The logger command is part of the util-linux package and is available from
.UR ftp://\:ftp.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
Linux Kernel Archive
.UE .