| LOGGER(1) | General Commands Manual | LOGGER(1) |
NAME
logger —
Send messages to system log daemon, or a log
file
SYNOPSIS
logger |
[-46bchiknsv-d
SD-f
FILE-h
HOST-H
HOSTNAME-I
PID-m
MSGID-o
OPTS-p
PRIO-P
PORT-r
SIZE:NUM-t
TAG-u
SOCKMESSAGE ] |
DESCRIPTIOMN
logger 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 syslogp(3) API
is always used but 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.
Without a MESSAGE argument,
logger waits for input on
stdin, consuming all data until EOF.
OPTIONS
This program follows the usual UNIX command line syntax:-4- Force
loggerto use IPv4 addresses only. -6- Force
loggerto use IPv6 addresses only. -b- Use RFC3164 (BSD) style format, default: RFC5424.
-c- Log to console (‘
LOG_CONS’) ifsyslog() fails to send message to syslogd(8). -dSD- Log this in the structured data (SD) field of an RFC5424 style log
message. See
-mfor caveats. Also, please note that sd has to be passed as one argument and will require careful quoting when used from the shell. -fFILE- Log file to write messages to, instead of syslog daemon.
loggeraccepts-f-as an alias for stdout. -Hhostname- Set the hostname in the header of the message to specified value. If not
specified, the host part of
gethostname(3)
will be used. This is the same as using the special character
‘
@’ as the hostname. -hhost- Send the message to the remote system host instead of logging it locally.
-IPID- Like
-i, but uses PID. Useful when logging from shell scripts that send multiple messages. E.g., the following arguments might be a useful template:logger -t $(basename $0) -I $$ -i- Log the process id of the logger process with each line
(‘
LOG_PID’). -k- Log to kernel /dev/kmsg if
/dev/log doesn't exist yet. Only works
on Linux systems and only if
-uSOCK and-fFILE are not used. Whensyslogdeventually starts, it will recognize these messages, due to not having kernel facility, and log them properly. Highly useful for userspace scripts and applications running beforesyslogdhas started. E.g., mount helpers and similar. -mMSGID- The MSGID used for the message. Requires RFC5424 support in syslogd(8) for receiving the message and also for storing it properly in a log file or sending remote in correctly formatted RFC5424 style.
-n- Open log file immediately
(‘
LOG_NDELAY’). -oOPTS- Set multicast options, separate multiple options with comma:
- iface=IFNAME
- Outbound interface when sending to a multicast group address. By default the kernel relies on the routing table, falling back to the default route if nothing more specific exists.
- ttl=<1..255>
- IP TTL of outbound syslog messages when sending to a multicast group. The default TTL for multicast is 1, meaning it is confined to the LAN.
-Pport- Send the message to the specified port
number on a remote system, which can be specified as a service name or as
a decimal number. The default is
“
syslog”. If an unknown service name is used,loggerprints a warning and falls back to port 514. -pPRIO- Priority, numeric or in facility.severity
pair format, default:
user.notice. -rSIZE:NUM- Controls log file rotation. SIZE denotes number of bytes before rotating, default: 200 kB. NUM denotes number of rotated files to keep when logging to a file, default: 5.
-s- Log to stderr as well as the system log.
-tTAG- Log using the specified tag, default: username.
-uSOCK- Log to UNIX domain socket SOCK instead of the default /dev/log.
-v- Show program version.
- MESSAGE
- Log message to write. Remember to use single/double quotes if calling
loggerfrom a shell prompt due to expansion the shell does. If no message is givenloggerwill read from stdin until EOF. In this mode every new row (newline separated) is converted into an independent syslogp(3) call.
EXAMPLES
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"
FILES
- FILE
- If a custom log file is selected, using
-fFILE, then this file is opened and written to bylogger. When log file rotation is enabled, using-rSIZE:NUM,loggercreates FILE.1 FILE.2 FILE.3.gz etc. - /dev/log
- Socket used for communicating with syslogd(8). When built on BSD /var/run/log is used.
SEE ALSO
syslogp(3) syslogd(8)AUTHORS
logger was originally written by Joachim
Wiberg to be a part of the
finit(1) system
monitor (PID 1), where it is called logit.
It is included here to complement
syslogd(8) and be
extended upon in the sysklogd project.
STANDARDS
Thelogger 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.| December 31, 2024 | sysklogd |
Maintained in troglobit/sysklogd as man/logger.1. Send corrections there, or read it on the mirror.