logger
Write messages to system log
TLDR
Log a message to syslog
SYNOPSIS
logger [options] [message]
PARAMETERS
-i
Log the process ID of the logger command.
-f
Log the contents of the specified file.
-h
Send the message to the specified host.
-p
Specify the priority (facility.level) of the message. For example, 'user.info' or 'local0.debug'.
-t
Add the specified tag to each message.
-u
Write to the specified socket instead of the standard system log.
--id
Same as -i, logs the process ID.
--rfc5424
Use RFC5424 format.
--stderr
Output messages to stderr, as well as the system log.
--server
Address and port to send RFC5424 messages to.
--size
Maximum size of the message, in bytes. Messages larger than this will be truncated.
The message to be logged.
DESCRIPTION
The logger command is a simple utility used to make entries in the system log. It provides a way for shell scripts and other applications to send messages to the system's logging daemon (usually syslogd or rsyslogd). These messages can be important status updates, error notifications, debugging information, or any other relevant data that needs to be recorded.
By default, logger writes to the standard system log. Configuration of where the message eventually ends up depends on the system logger configuration, which is usually found in /etc/syslog.conf or /etc/rsyslog.conf. logger is a valuable tool for developers and system administrators to track events and diagnose issues on Linux systems. It's widely used in scripts and automated tasks to provide a persistent record of activities, enhancing monitoring and troubleshooting capabilities.
CAVEATS
The specific behavior of logger depends on the configuration of the system's logging daemon. The maximum message size might be limited by the system logger configuration. Incorrect priority settings may lead to messages being ignored or misclassified.
PRIORITY LEVELS
Priority is composed of a facility and a level. Common facilities include 'user', 'kern', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', and 'local0' through 'local7'. Common levels include 'emerg', 'alert', 'crit', 'err', 'warn', 'notice', 'info', and 'debug'.
Example: '-p daemon.err'
EXIT STATUS
The logger command returns 0 on success and a non-zero value on failure.
HISTORY
The logger command has been a standard utility in Unix-like operating systems for a long time, existing since the early days of Unix. It provides a simple and reliable way to send log messages from the command line. Over time, its functionality has remained relatively consistent, focusing on basic message logging capabilities. The primary use-case has always been scripting and system administration tasks.
SEE ALSO
syslogd(8), rsyslogd(8), journalctl(1)