LOGGER(1)

NAME
logger - Send messages to system log, or a log file

SYNOPSIS
logger [-chiknsv] [-d SD] [-f FILE] [-m MSGID] [-p PRIO] [-r SIZE:NUM] [-t TAG] [-u SOCK] [MESSAGE]

DESCRIPTIOMN
logger can be used to log messages to the system log daemon from a UNIX shell, or script. Optionally a stand-alone log file can be used, in which case the syslogp(3) API is still used but syslogd is bypassed. This log file can also be automatically log rotated.

Without a MESSAGE argument logger reads input from stdin.

OPTIONS
This program follows the usual UNIX command line syntax:

-c  Log to console ‘(LOG_CONS’) if syslog() fails to send message to syslogd(8).

-d 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.

-f FILE
    Log file to write messages to, instead of syslog daemon. logger accepts -f- as an alias for stdout.

-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 -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.

-m 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.

-n  Open log file immediately ‘(LOG_NDELAY’).

-p PRIO
    Priority, numeric or facility.severity pair.

-r 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.

-s  Log to stderr as well as the system log.

-t TAG
    Log using the specified tag, default: username.

-u SOCK
    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 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.

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 -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.

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
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.