sysklogd/man/logger.1
Joachim Wiberg 7bd017be0a logger: fix default log severity info -> notice, like other loggers
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-08-01 12:48:31 +02:00

240 lines
6.5 KiB
Groff

.\" -*- nroff -*-
.\" Copyright (c) 2018-2022 Joachim Wiberg <troglobit@gmail.com>
.\" 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. 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.
.Dd August 1, 2022
.Dt LOGGER 1
.Os sysklogd
.Sh NAME
.Nm logger
.Nd Send messages to system log daemon, or a log file
.Sh SYNOPSIS
.Nm
.Op Fl 46bchiknsv
.Op Fl d Ar SD
.Op Fl f Ar FILE
.Op Fl h Ar HOST
.Op Fl H Ar HOSTNAME
.Op Fl I Ar PID
.Op Fl m Ar MSGID
.Op Fl p Ar PRIO
.Op Fl P Ar PORT
.Op Fl r Ar SIZE:NUM
.Op Fl t Ar TAG
.Op Fl u Ar SOCK
.Op Ar MESSAGE
.Sh DESCRIPTIOMN
.Nm
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
.Xr syslogp 3
API is always used but
.Nm syslogd
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.
.Pp
Without a
.Ar MESSAGE
argument,
.Nm
waits for input on
.Ar stdin ,
consuming all data until EOF.
.Sh OPTIONS
This program follows the usual UNIX command line syntax:
.Bl -tag -width Ds
.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.
.It Fl c
Log to console
.Ql ( LOG_CONS )
if
.Fn syslog
fails to send message to
.Xr syslogd 8 .
.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.
.It Fl f Ar FILE
Log file to write messages to, instead of syslog daemon.
.Nm
accepts
.Fl f-
as an alias for
.Ar stdout .
.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.
.It Fl h Ar host
Send the message to the remote system
.Ar host
instead of logging it locally.
.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
.It Fl i
Log the process id of the logger process with each line
.Ql ( LOG_PID ) .
.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.
.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.
.It Fl n
Open log file immediately
.Ql ( LOG_NDELAY ) .
.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.
.It Fl p Ar PRIO
Priority, numeric or in
.Ar facility.severity
pair format, default:
.Nm user.notice .
.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.
.It Fl s
Log to stderr as well as the system log.
.It Fl t Ar TAG
Log using the specified tag, default: username.
.It Fl u Ar SOCK
Log to UNIX domain socket
.Ar SOCK
instead of the default
.Pa /dev/log .
.It Fl v
Show program version.
.It Ar MESSAGE
Log message to write. Remember to use single/double quotes if calling
.Nm
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
.Xr syslogp 3
call.
.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
.Sh FILES
.Bl -tag -width /dev/log -compact
.It Ar FILE
If a custom log file is selected, using
.Fl f Ar FILE ,
then this file is opened and written to by
.Nm .
When log file rotation is enabled, using
.Fl r Ar SIZE:NUM ,
.Nm
creates
.Pa FILE.1 FILE.2 FILE.3.gz
etc.
.It Pa /dev/log
Socket used for communicating with
.Xr syslogd 8 .
When built on BSD
.Pa /var/run/log
is used.
.El
.Sh SEE ALSO
.Xr syslogp 3
.Xr syslogd 8
.Sh AUTHORS
.Nm
was originally written by Joachim Wiberg to be a part of the
.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
command is expected to be IEEE Std 1003.2 ("POSIX.2") compatible, with
extensions for RFC5424 from NetBSD and custom log file and log file
rotation unique to the sysklogd project.