LOGGER(1) | User Commands | LOGGER(1) |
NAME¶
logger - enter messages into the system log
SYNOPSIS¶
logger [options] message
DESCRIPTION¶
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.
OPTIONS¶
-d, --udp
See also --server and --socket to specify where to connect.
-e, --skip-empty
-f, --file file
-i
--id[=id]
Note that the system logging infrastructure (for example systemd when listening on /dev/log) may follow local socket credentials to overwrite the PID specified in the message. logger(1) is able to set those socket credentials to the given id, but only if you have root permissions and a process with the specified PID exists, otherwise the socket credentials are not modified and the problem is silently ignored.
--journald[=file]
logger --journald <<end MESSAGE_ID=67feb6ffbaf24c5cbec13c008dd72309 MESSAGE=The dogs bark, but the caravan goes on. DOGS=bark CARAVAN=goes on end
logger --journald=entry.txt
Notice 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(1) will display MESSAGE field. Use journalctl --output json-pretty to see rest of the fields.
To include newlines in MESSAGE, specify MESSAGE several times. This is handled as a special case, other fields will be stored as an array in the journal if they appear multiple times.
--msgid msgid
-n, --server server
--no-act
--octet-count
-P, --port port
-p, --priority priority
--prio-prefix
If the prefix contains no facility, the facility defaults to what is specified by the -p option. Similarly, if no prefix is provided, the line is logged using the priority given with -p.
This option doesn’t affect a command-line message.
--rfc3164
--rfc5424[=without]
The notq value suppresses the time-quality structured data from the submitted message. The time-quality information shows whether the local clock was synchronized plus the maximum number of microseconds the timestamp might be off. The time quality is 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 microseconds 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.
-s, --stderr
--sd-id name[@digits]
logger currently generates the timeQuality standardized element only. RFC 5424 also describes the elements origin (with parameters ip, enterpriseId, software and swVersion) and meta (with parameters sequenceId, sysUpTime and language). These element IDs may be specified without the @digits suffix.
--sd-param name=value
logger --rfc5424 --sd-id zoo@123 \
--sd-param tiger="hungry" \
--sd-param zebra="running" \
--sd-id manager@123 \
--sd-param onMeeting="yes" \
"this is message"
produces:
<13>1 2015-10-01T14:07:59.168662+02:00 ws kzak - - [timeQuality tzKnown="1" isSynced="1" syncAccuracy="218616"][zoo@123 tiger="hungry" zebra="running"][manager@123 onMeeting="yes"] this is message
-S, --size size
Most receivers accept messages larger than 1KiB over any type of syslog protocol. As such, the --size option affects logger in 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 the selected options and the hostname length. As a rule of thumb, headers are usually not longer than 50 to 80 characters. When selecting a maximum message size, it is important to ensure that the receiver supports the max size as well, otherwise messages may become truncated. Again, as a rule of thumb two to four KiB message size should generally be OK, whereas anything larger should be verified to work.
--socket-errors[=mode]
The default mode is auto. When errors are not enabled lost messages are not communicated and will result to successful exit status of logger(1) invocation.
-T, --tcp
See also --server and --socket to specify where to connect.
-t, --tag tag
-u, --socket socket
--
-h, --help
-V, --version
EXIT STATUS¶
The logger utility exits 0 on success, and >0 if an error occurs.
FACILITIES AND LEVELS¶
Valid facility names are:
auth
authpriv for security information of a sensitive nature
cron
daemon
ftp
kern cannot be generated from userspace process, automatically
converted to user
lpr
mail
news
syslog
user
uucp
local0
to
local7
security deprecated synonym for auth
Valid level names are:
emerg
alert
crit
err
warning
notice
info
debug
panic deprecated synonym for emerg
error deprecated synonym for err
warn deprecated synonym for warning
For the priority order and intended purposes of these facilities and levels, see syslog(3).
CONFORMING TO¶
The logger command is expected to be IEEE Std 1003.2 ("POSIX.2") compatible.
EXAMPLES¶
logger System rebooted
logger -p local0.notice -t HOSTIDM -f /dev/idmc
logger -n loghost.example.com System rebooted
AUTHORS¶
The logger command was originally written by University of California in 1983-1993 and later rewritten by Karel Zak <kzak@redhat.com>, Rainer Gerhards <rgerhards@adiscon.com>, and Sami Kerola <kerolasa@iki.fi>.
SEE ALSO¶
REPORTING BUGS¶
For bug reports, use the issue tracker at <https://github.com/util-linux/util-linux/issues>.
AVAILABILITY¶
The logger command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.
2024-04-24 | util-linux 2.40.2 |