Linux Command: logger
Send messages to the system log
logger makes entries in the system log (syslog). It provides a way for shell scripts and commands to write messages to the standard logging infrastructure. logger is the proper way for scripts to log messages. Instead of writing to custom log files, logger sends messages to rsyslog/journald where they are managed, rotated, and searchable. logger supports setting priority levels, tags, and facilities. Messages appear in /var/log/syslog, journalctl, or other configured log destinations.
Syntax
logger [OPTION]... [MESSAGE]Key Options
-pโ Set priority (facility.level)-tโ Set tag (program name)-sโ Also output to stderr-iโ Include PID
Examples
Simple log message
logger "Backup completed successfully"Tagged message
logger -t backup-script "Daily backup finished, 2.5GB compressed"Error priority
logger -p user.err -t myapp "Failed to connect to database"Pro Tips
- -t tag makes log messages filterable: journalctl -t backup-script shows only your messages.
- Priorities: emerg, alert, crit, err, warning, notice, info, debug. Default is user.notice.
- Log messages are stored in plain text and may be forwarded to remote servers. Never log passwords or tokens.
Learn more: Full logger reference โ