2019-10-13 18:14:51 +05:30
|
|
|
.\" -*- nroff -*-
|
2022-08-01 15:03:47 +05:30
|
|
|
.\" Copyright (c) 2018-2022 Joachim Wiberg <troglobit@gmail.com>
|
2019-10-13 18:14:51 +05:30
|
|
|
.\" All rights reserved.
|
2019-12-09 22:59:59 +05:30
|
|
|
.\"
|
2019-10-13 18:14:51 +05:30
|
|
|
.\" 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. 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.
|
2022-08-01 15:03:47 +05:30
|
|
|
.Dd August 1, 2022
|
2019-12-09 22:02:46 +05:30
|
|
|
.Dt LOGGER 1
|
2021-02-21 19:25:17 +05:30
|
|
|
.Os sysklogd
|
2019-10-13 18:14:51 +05:30
|
|
|
.Sh NAME
|
|
|
|
.Nm logger
|
2022-07-31 21:02:13 +05:30
|
|
|
.Nd Send messages to system log daemon, or a log file
|
2019-10-13 18:14:51 +05:30
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm
|
2022-07-31 14:16:32 +05:30
|
|
|
.Op Fl 46bchiknsv
|
2019-11-08 02:40:27 +05:30
|
|
|
.Op Fl d Ar SD
|
2019-10-13 18:14:51 +05:30
|
|
|
.Op Fl f Ar FILE
|
2022-07-31 14:16:32 +05:30
|
|
|
.Op Fl h Ar HOST
|
2022-07-31 15:18:58 +05:30
|
|
|
.Op Fl H Ar HOSTNAME
|
2022-07-31 15:33:57 +05:30
|
|
|
.Op Fl I Ar PID
|
2019-11-08 02:11:33 +05:30
|
|
|
.Op Fl m Ar MSGID
|
2019-10-13 18:14:51 +05:30
|
|
|
.Op Fl p Ar PRIO
|
2022-07-31 14:16:32 +05:30
|
|
|
.Op Fl P Ar PORT
|
2019-10-25 19:22:14 +05:30
|
|
|
.Op Fl r Ar SIZE:NUM
|
2019-10-13 18:14:51 +05:30
|
|
|
.Op Fl t Ar TAG
|
2019-11-08 02:23:51 +05:30
|
|
|
.Op Fl u Ar SOCK
|
2019-10-25 19:22:14 +05:30
|
|
|
.Op Ar MESSAGE
|
2019-10-13 18:14:51 +05:30
|
|
|
.Sh DESCRIPTIOMN
|
|
|
|
.Nm
|
2022-07-31 21:02:13 +05:30
|
|
|
can be used to log messages to a local or remote system log daemon, or a
|
|
|
|
log file, from a UNIX shell, or script. The new
|
2019-11-15 13:54:23 +05:30
|
|
|
.Xr syslogp 3
|
2022-07-31 21:02:13 +05:30
|
|
|
API is always used but
|
2019-11-15 13:54:23 +05:30
|
|
|
.Nm syslogd
|
2022-07-31 21:02:13 +05:30
|
|
|
is bypassed in the remote log daemon and local log file use-cases. The
|
|
|
|
log file is also be automatically rotated. See below for log rotation
|
|
|
|
options.
|
2019-11-15 13:54:23 +05:30
|
|
|
.Pp
|
|
|
|
Without a
|
2019-10-29 13:38:37 +05:30
|
|
|
.Ar MESSAGE
|
2022-07-31 21:02:13 +05:30
|
|
|
argument,
|
2019-10-29 13:38:37 +05:30
|
|
|
.Nm
|
2022-07-31 21:02:13 +05:30
|
|
|
waits for input on
|
|
|
|
.Ar stdin ,
|
|
|
|
consuming all data until EOF.
|
2019-10-13 18:14:51 +05:30
|
|
|
.Sh OPTIONS
|
|
|
|
This program follows the usual UNIX command line syntax:
|
|
|
|
.Bl -tag -width Ds
|
2022-07-31 14:16:32 +05:30
|
|
|
.It Fl 4
|
|
|
|
Force
|
|
|
|
.Nm
|
|
|
|
to use IPv4 addresses only.
|
|
|
|
.It Fl 6
|
|
|
|
Force
|
|
|
|
.Nm
|
|
|
|
to use IPv6 addresses only.
|
|
|
|
.It Fl b
|
|
|
|
Use RFC3164 (BSD) style format, default: RFC5424.
|
2019-11-08 01:38:01 +05:30
|
|
|
.It Fl c
|
|
|
|
Log to console
|
|
|
|
.Ql ( LOG_CONS )
|
|
|
|
if
|
|
|
|
.Fn syslog
|
|
|
|
fails to send message to
|
|
|
|
.Xr syslogd 8 .
|
2019-11-08 02:40:27 +05:30
|
|
|
.It Fl d Ar SD
|
|
|
|
Log this in the structured data (SD) field of an RFC5424 style log
|
|
|
|
message. See
|
|
|
|
.Fl m
|
|
|
|
for caveats. Also, please note that
|
|
|
|
.Ar sd
|
|
|
|
has to be passed as one argument and will require careful quoting when
|
|
|
|
used from the shell.
|
2019-10-13 18:14:51 +05:30
|
|
|
.It Fl f Ar FILE
|
2019-10-25 19:22:14 +05:30
|
|
|
Log file to write messages to, instead of syslog daemon.
|
2019-10-29 13:38:37 +05:30
|
|
|
.Nm
|
|
|
|
accepts
|
|
|
|
.Fl f-
|
|
|
|
as an alias for
|
|
|
|
.Ar stdout .
|
2022-07-31 15:18:58 +05:30
|
|
|
.It Fl H Ar hostname
|
|
|
|
Set the hostname in the header of the message to specified value.
|
|
|
|
If not specified, host part of
|
|
|
|
.Xr gethostname 3
|
|
|
|
will be used.
|
2022-07-31 14:16:32 +05:30
|
|
|
.It Fl h Ar host
|
|
|
|
Send the message to the remote system
|
|
|
|
.Ar host
|
|
|
|
instead of logging it locally.
|
2022-07-31 15:33:57 +05:30
|
|
|
.It Fl I Ar PID
|
|
|
|
Like
|
|
|
|
.Fl i ,
|
|
|
|
but uses
|
|
|
|
.Ar PID .
|
|
|
|
Useful when logging from shell scripts that send multiple messages.
|
|
|
|
E.g., the following arguments might be a useful template:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
logger -t $(basename $0) -I $$
|
|
|
|
.Ed
|
2019-11-08 01:55:32 +05:30
|
|
|
.It Fl i
|
|
|
|
Log the process id of the logger process with each line
|
|
|
|
.Ql ( LOG_PID ) .
|
2021-06-22 02:42:54 +05:30
|
|
|
.It Fl k
|
|
|
|
Log to kernel
|
|
|
|
.Pa /dev/kmsg
|
|
|
|
if
|
|
|
|
.Pa /dev/log
|
|
|
|
doesn't exist yet. Only works on Linux systems and only if
|
|
|
|
.Fl u Ar SOCK
|
|
|
|
and
|
|
|
|
.Fl f Ar FILE
|
|
|
|
are
|
|
|
|
.Sy not used .
|
|
|
|
When
|
|
|
|
.Nm syslogd
|
|
|
|
eventually starts, it will recognize these messages, due to not having
|
|
|
|
kernel facility, and log them properly. Highly useful for userspace
|
|
|
|
scripts and applications running before
|
|
|
|
.Nm syslogd
|
|
|
|
has started. E.g., mount helpers and similar.
|
2019-11-08 02:11:33 +05:30
|
|
|
.It Fl m Ar MSGID
|
|
|
|
The MSGID used for the message. Requires RFC5424 support in
|
|
|
|
.Xr syslogd 8
|
|
|
|
for receiving the message and also for storing it properly in a log file
|
|
|
|
or sending remote in correctly formatted RFC5424 style.
|
2019-11-08 01:58:49 +05:30
|
|
|
.It Fl n
|
|
|
|
Open log file immediately
|
|
|
|
.Ql ( LOG_NDELAY ) .
|
2022-07-31 14:16:32 +05:30
|
|
|
.It Fl P Ar port
|
|
|
|
Send the message to the specified
|
|
|
|
.Ar port
|
|
|
|
number on a remote system,
|
|
|
|
which can be specified as a service name
|
|
|
|
or as a decimal number.
|
|
|
|
The default is
|
|
|
|
.Dq Li syslog .
|
|
|
|
If an unknown service name is used,
|
|
|
|
.Nm
|
|
|
|
prints a warning and falls back to port 514.
|
2019-10-13 18:14:51 +05:30
|
|
|
.It Fl p Ar PRIO
|
2019-10-25 19:22:14 +05:30
|
|
|
Priority, numeric or
|
2019-10-29 13:38:37 +05:30
|
|
|
.Ar facility.severity
|
2019-10-25 19:22:14 +05:30
|
|
|
pair.
|
|
|
|
.It Fl r Ar SIZE:NUM
|
|
|
|
Controls log file rotation.
|
|
|
|
.Ar SIZE
|
|
|
|
denotes number of bytes before rotating, default: 200 kB.
|
|
|
|
.Ar NUM
|
|
|
|
denotes number of rotated files to keep when logging to a file, default:
|
|
|
|
5.
|
2019-10-13 18:14:51 +05:30
|
|
|
.It Fl s
|
|
|
|
Log to stderr as well as the system log.
|
|
|
|
.It Fl t Ar TAG
|
|
|
|
Log using the specified tag, default: username.
|
2019-11-08 02:23:51 +05:30
|
|
|
.It Fl u Ar SOCK
|
|
|
|
Log to UNIX domain socket
|
|
|
|
.Ar SOCK
|
|
|
|
instead of the default
|
|
|
|
.Pa /dev/log .
|
2019-10-13 18:14:51 +05:30
|
|
|
.It Fl v
|
|
|
|
Show program version.
|
2019-10-25 19:22:14 +05:30
|
|
|
.It Ar MESSAGE
|
2021-02-21 19:24:59 +05:30
|
|
|
Log message to write. Remember to use single/double quotes if calling
|
2019-10-25 19:22:14 +05:30
|
|
|
.Nm
|
2019-10-29 13:38:37 +05:30
|
|
|
from a shell prompt due to expansion the shell does. If no message is
|
|
|
|
given
|
|
|
|
.Nm
|
|
|
|
will read from
|
|
|
|
.Ar stdin
|
|
|
|
until EOF. In this mode every new row (newline separated) is converted
|
|
|
|
into an independent
|
2019-11-08 02:18:53 +05:30
|
|
|
.Xr syslogp 3
|
2019-10-29 13:38:37 +05:30
|
|
|
call.
|
2019-10-13 18:14:51 +05:30
|
|
|
.El
|
|
|
|
.Sh EXAMPLES
|
|
|
|
.Bd -unfilled -offset left
|
|
|
|
logger -t dropbear -p auth.notice "Successful login for user 'admin' from 1.2.3.4"
|
|
|
|
logger -t udhcpc -f /tmp/script.log "New lease 1.2.3.200 obtained for interface eth0"
|
|
|
|
.Ed
|
2019-10-25 19:22:14 +05:30
|
|
|
.Sh FILES
|
2019-11-08 02:23:51 +05:30
|
|
|
.Bl -tag -width /dev/log -compact
|
2019-10-25 19:22:14 +05:30
|
|
|
.It Ar FILE
|
2019-11-08 02:23:51 +05:30
|
|
|
If a custom log file is selected, using
|
2019-10-25 19:22:14 +05:30
|
|
|
.Fl f Ar FILE ,
|
|
|
|
then this file is opened and written to by
|
|
|
|
.Nm .
|
2019-11-08 02:23:51 +05:30
|
|
|
When log file rotation is enabled, using
|
2019-10-25 19:22:14 +05:30
|
|
|
.Fl r Ar SIZE:NUM ,
|
|
|
|
.Nm
|
2019-11-08 02:23:51 +05:30
|
|
|
creates
|
2019-10-25 19:22:14 +05:30
|
|
|
.Pa FILE.1 FILE.2 FILE.3.gz
|
|
|
|
etc.
|
2019-11-08 02:23:51 +05:30
|
|
|
.It Pa /dev/log
|
|
|
|
Socket used for communicating with
|
2019-10-25 19:22:14 +05:30
|
|
|
.Xr syslogd 8 .
|
2019-11-08 02:23:51 +05:30
|
|
|
When built on BSD
|
|
|
|
.Pa /var/run/log
|
|
|
|
is used.
|
2019-10-25 19:22:14 +05:30
|
|
|
.El
|
2019-10-13 18:14:51 +05:30
|
|
|
.Sh SEE ALSO
|
2019-11-08 02:18:53 +05:30
|
|
|
.Xr syslogp 3
|
2019-10-13 18:14:51 +05:30
|
|
|
.Xr syslogd 8
|
|
|
|
.Sh AUTHORS
|
|
|
|
.Nm
|
2020-09-01 00:58:25 +05:30
|
|
|
was originally written by Joachim Wiberg to be a part of the
|
2019-10-13 18:14:51 +05:30
|
|
|
.Xr finit 1
|
|
|
|
system monitor (PID 1), where it is called
|
|
|
|
.Nm logit .
|
|
|
|
It is included here to complement
|
|
|
|
.Xr syslogd 8
|
|
|
|
and be extended upon in the sysklogd project.
|
|
|
|
.Sh STANDARDS
|
|
|
|
The
|
|
|
|
.Nm
|
2019-10-25 19:22:14 +05:30
|
|
|
command is expected to be IEEE Std 1003.2 ("POSIX.2") compatible, with
|
2019-11-08 02:23:51 +05:30
|
|
|
extensions for RFC5424 from NetBSD and custom log file and log file
|
|
|
|
rotation unique to the sysklogd project.
|