logger Command
Intermediate Logging & Monitoring man(1)Send messages to the system log
👁 12 views
📅 Updated: Mar 15, 2026
SYNTAX
logger [OPTION]... [MESSAGE]
What Does logger Do?
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.
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.
Options & Flags
| Option | Description | Example |
|---|---|---|
| -p | Set priority (facility.level) | logger -p local0.error "Database connection failed" |
| -t | Set tag (program name) | logger -t myapp "Starting backup" |
| -s | Also output to stderr | logger -s -t deploy "Deploy complete" |
| -i | Include PID | logger -it myapp "Process started" |
Practical Examples
#1 Simple log message
Writes a message to syslog.
$ logger "Backup completed successfully"#2 Tagged message
Logs with a tag for easy filtering.
$ logger -t backup-script "Daily backup finished, 2.5GB compressed"#3 Error priority
Logs an error-level message.
$ logger -p user.err -t myapp "Failed to connect to database"#4 In a script
Script that logs start, success, and failure.
$ #!/bin/bash\nlogger -t deploy "Deploy started"\n./deploy.sh && logger -t deploy "Deploy succeeded" || logger -t deploy -p user.err "Deploy FAILED"#5 Verify message
Logs a message and immediately checks it.
$ logger -t test "Hello syslog" && journalctl -t test --no-pager -n 1#6 With stderr output
Logs to syslog AND prints to stderr.
$ logger -s -t myapp "Critical: disk space low"Tips & Best Practices
Use tags for filtering: -t tag makes log messages filterable: journalctl -t backup-script shows only your messages.
Priority levels: Priorities: emerg, alert, crit, err, warning, notice, info, debug. Default is user.notice.
Do not log secrets: Log messages are stored in plain text and may be forwarded to remote servers. Never log passwords or tokens.
Frequently Asked Questions
How do I log from a script?
logger -t scriptname "message" writes to syslog. View with journalctl -t scriptname.
How do I set log priority?
logger -p facility.level message. Common: user.info, user.err, local0.warning.
Where do logger messages go?
To syslog — typically /var/log/syslog or /var/log/messages. Also visible via journalctl.
Related Commands
More Logging & Monitoring Commands
Master Linux with Professional eBooks
Curated IT eBooks covering Linux, DevOps, Cloud, and more
Browse Books →