LOGGER(1)
LOGGER(1) General Commands Manual LOGGER(1)

logger
Send messages to system log daemon, or a log file

logger [
-46bchiknsv
] [
-d SD
] [
-f FILE
] [
-h HOST
] [
-H HOSTNAME
] [
-I PID
] [
-m MSGID
] [
-p PRIO
] [
-P PORT
] [
-r SIZE:NUM
] [
-t TAG
] [
-u SOCK
] [
MESSAGE
]

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.

This program follows the usual UNIX command line syntax:
Force logger to use IPv4 addresses only.
Force logger to use IPv6 addresses only.
Use RFC3164 (BSD) style format, default: RFC5424.
Log to console (‘LOG_CONS’) if syslog() fails to send message to syslogd(8).
SD
Log this in the structured data (SD) field of an RFC5424 style log message. See -m for caveats. Also, please note that sd has to be passed as one argument and will require careful quoting when used from the shell.
FILE
Log file to write messages to, instead of syslog daemon. logger accepts -f- as an alias for stdout.
hostname
Set the hostname in the header of the message to specified value. If not specified, host part of gethostname(3) will be used.
host
Send the message to the remote system host instead of logging it locally.
PID
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 $$
    
Log the process id of the logger process with each line (‘LOG_PID’).
Log to kernel /dev/kmsg if /dev/log doesn't exist yet. Only works on Linux systems and only if -u SOCK and -f FILE are not used. When 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 syslogd has started. E.g., mount helpers and similar.
MSGID
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.
Open log file immediately (‘LOG_NDELAY’).
port
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, logger prints a warning and falls back to port 514.
PRIO
Priority, numeric or in facility.severity pair format, default: user.notice.
SIZE: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.
Log to stderr as well as the system log.
TAG
Log using the specified tag, default: username.
SOCK
Log to UNIX domain socket SOCK instead of the default /dev/log.
Show program version.
MESSAGE
Log message to write. Remember to use single/double quotes if calling logger from a shell prompt due to expansion the shell does. If no message is given logger will read from stdin until EOF. In this mode every new row (newline separated) is converted into an independent syslogp(3) call.

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"

FILE
If a custom log file is selected, using -f FILE, then this file is opened and written to by logger. When log file rotation is enabled, using -r SIZE:NUM, logger creates 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.

syslogp(3) syslogd(8)

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.

The logger 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.
April 30, 2023 sysklogd