Linux "logger" Command Line Options and Examples
enter messages into the system log

logger makes entries in the system log. When the optional message argument is present, it is written to the log. If it is not present, and the -f option is not given either, then standard input is logged.


Usage:

logger [options] [message]






Command Line Options:

-d
Use datagrams (UDP) only. By default the connection is tried to the syslog port defined in /etc/services, which is often 514.
logger -d ...
-e
Ignore empty lines when processing files. An empty line is defined to be a line without any characters. Thus a line consist‐ing only of whitespace is NOT considered empty. Note that when the --prio-prefix option is specified, the priority is notpart of the line. Thus an empty line in this mode is a line that does not have any characters after the priority prefix (e.g.<13>).
logger -e ...
-f
Log the contents of the specified file. This option cannot be combined with a command-line message.
logger -f ...
-i
Log the PID of the logger process with each line.
logger -i ...
--id[
Log the PID of the logger process with each line. When the optional argument id is specified, then it is used instead of thelogger command's PID. The use of --id=$$ (PPID) is recommended in scripts that send several messages.Note that the system logging infrastructure (for example systemd when listening on /dev/log) may follow local socket creden‐tials to overwrite the PID specified in the message. logger(1) is able to set those socket credentials to the given id, butonly if you have root permissions and a process with the specified PID exists, otherwise the socket credentials are not modi‐fied and the problem is silently ignored.
logger --id[ ...
--journald[
Write a systemd journal entry. The entry is read from the given file, when specified, otherwise from standard input. Eachline must begin with a field that is accepted by journald; see systemd.journal-fields(7) for details. The use of a MESSAGE_IDfield is generally a good idea, as it makes finding entries easy. Examples:logger --journald <<endMESSAGE_ID=67feb6ffbaf24c5cbec13c008dd72309MESSAGE=The dogs bark, but the caravan goes on.DOGS=barkCARAVAN=goes onendlogger --journald=entry.txtNotice that --journald will ignore values of other options, such as priority. If priority is needed it must be within input,and use PRIORITY field. The simple execution of journalctl will display MESSAGE field. Use journalctl --output json-prettyto see rest of the fields.
logger --journald[ ...
--msgid
Sets the RFC5424 MSGID field. Note that the space character is not permitted inside of msgid. This option is only used if
logger --msgid ...
--rfc5424
is specified as well; otherwise, it is silently ignored.
logger --rfc5424 ...
-n
Write to the specified remote syslog server instead of to the system log socket. Unless --udp or --tcp is specified, loggerwill first try to use UDP, but if this fails a TCP connection is attempted.
logger -n ...
--no-act
Causes everything to be done except for writing the log message to the system log, and removing the connection or the journal.This option can be used together with --stderr for testing purposes.
logger --no-act ...
--octet-count
Use the RFC 6587 octet counting framing method for sending messages. When this option is not used, the default is no framingon UDP, and RFC6587 non-transparent framing (also known as octet stuffing) on TCP.
logger --octet-count ...
-P
Use the specified port. When this option is not specified, the port defaults to syslog for udp and to syslog-conn for tcpconnections.
logger -P ...
-p
Enter the message into the log with the specified priority. The priority may be specified numerically or as a facility.levelpair. For example, -p local3.info logs the message as informational in the local3 facility. The default is user.notice.
logger -p ...
--prio-prefix
Look for a syslog prefix on every line read from standard input. This prefix is a decimal number within angle brackets thatencodes both the facility and the level. The number is constructed by multiplying the facility by 8 and then adding thelevel. For example, local0.info, meaning facility=16 and level=6, becomes <134>.If the prefix contains no facility, the facility defaults to what is specified by the -p option. Similarly, if no prefix isprovided, the line is logged using the priority given with -p.This option doesn't affect a command-line message.
logger --prio-prefix ...
--rfc3164
Use the RFC 3164 BSD syslog protocol to submit messages to a remote server.
logger --rfc3164 ...
--rfc5424[
Use the RFC 5424 syslog protocol to submit messages to a remote server. The optional without argument can be a comma-sepa‐rated list of the following values: notq, notime, nohost.The notq value suppresses the time-quality structured data from the submitted message. The time-quality information showswhether the local clock was synchronized plus the maximum number of microseconds the timestamp might be off. The time qualityis also automatically suppressed when --sd-id timeQuality is specified.The notime value (which implies notq) suppresses the complete sender timestamp that is in ISO-8601 format, including microsec‐onds and timezone.The nohost value suppresses gethostname(2) information from the message header.The RFC 5424 protocol has been the default for logger since version 2.26.
logger --rfc5424[ ...
-s
Output the message to standard error as well as to the system log.
logger -s ...
--sd-id
Specifies a structured data element ID for an RFC 5424 message header. The option has to be used before --sd-param to intro‐duce a new element. The number of structured data elements is unlimited. The ID (name plus possibly @digits) is case-sensi‐tive and uniquely identifies the type and purpose of the element. The same ID must not exist more than once in a message.The @digits part is required for user-defined non-standardized IDs.logger currently generates the timeQuality standardized element only. RFC 5424 also describes the elements origin (withparameters ip, enterpriseId, software and swVersion) and meta (with parameters sequenceId, sysUpTime and language). Theseelement IDs may be specified without the @digits suffix.
logger --sd-id ...
--sd-param
Specifies a structured data element parameter, a name and value pair. The option has to be used after --sd-id and may bespecified more than once for the same element. Note that the quotation marks around value are required and must be escaped onthe command line.logger --rfc5424 --sd-id zoo@123 \
logger --sd-param ...
--size
Sets the maximum permitted message size to size. The default is 1KiB characters, which is the limit traditionally used andspecified in RFC 3164. With RFC 5424, this limit has become flexible. A good assumption is that RFC 5424 receivers can atleast process 4KiB messages.Most receivers accept messages larger than 1KiB over any type of syslog protocol. As such, the --size option affects loggerin all cases (not only when --rfc5424 was used).Note: the message-size limit limits the overall message size, including the syslog header. Header sizes vary depending on theselected options and the hostname length. As a rule of thumb, headers are usually not longer than 50 to 80 characters. Whenselecting a maximum message size, it is important to ensure that the receiver supports the max size as well, otherwise mes‐sages may become truncated. Again, as a rule of thumb two to four KiB message size should generally be OK, whereas anythinglarger should be verified to work.
logger --size ...
--socket-errors[
Print errors about Unix socket connections. The mode can be a value of off, on, or auto. When the mode is auto logger willdetect if the init process is systemd, and if so assumption is made /dev/log can be used early at boot. Other init systemslack of /dev/log will not cause errors that is identical with messaging using openlog(3) system call. The logger(1) beforeversion 2.26 used openlog, and hence was unable to detected loss of messages sent to Unix sockets.The default mode is auto. When errors are not enabled lost messages are not communicated and will result to successful returnvalue of logger(1) invocation.
logger --socket-errors[ ...
-T
Use stream (TCP) only. By default the connection is tried to the syslog-conn port defined in /etc/services, which is often601.
logger -T ...
-t
Mark every line to be logged with the specified tag. The default tag is the name of the user logged in on the terminal (or auser name based on effective user ID).
logger -t ...
-u
Write to the specified socket instead of to the system log socket.
logger -u ...
--
End the argument list. This allows the message to start with a hyphen (-).
logger -- ...
-V
Display version information and exit.
logger -V ...
-h
Display help text and exit.RETURN VALUEThe logger utility exits 0 on success, and >0 if an error occurs.FACILITIES AND LEVELSValid facility names are:authauthpriv for security information of a sensitive naturecrondaemonftpkern cannot be generated from userspace process, automatically converted to userlprmailnewssysloguseruucplocal0tolocal7security deprecated synonym for authValid level names are:emergalertcriterrwarningnoticeinfodebugpanic deprecated synonym for emergerror deprecated synonym for errwarn deprecated synonym for warningFor the priority order and intended purposes of these facilities and levels, see syslog(3).EXAMPLESlogger System rebootedlogger -p local0.notice -t HOSTIDM -f /dev/idmclogger -n loghost.example.com System rebooted
logger -h ...