Send messages to the system log (syslog/journald).
low risk
logger writes messages to the system journal or syslog. Used in scripts to emit structured log entries that appear in journalctl alongside system logs — crucial for script audit trails and integration with centralized logging.
| Flag | Meaning |
|---|---|
-t --tag | Add a tag/identifier to messages |
-p --priority | Set message priority (e.g., user.error) |
-s --stderr | Also print to stderr |
-n --server | Send to remote syslog server |
logger -t deploy 'Deployment v1.2.3 started by ec2-user'Log a tagged deployment event · explain & risk-check →logger -p user.error -t myapp 'Database connection failed'Log an error with priority · explain & risk-check →echo 'Backup complete' | logger -t backupPipe output to syslog · explain & risk-check →Add `logger -t $(basename $0) "Starting: $0 $*"` to the top of every admin script — creates an automatic audit trail in journald for all script executions.
Reference text is hand-written and may be incomplete — check man logger for your version. Test destructive commands on a non-production system first.