logger flags & options

Basic usage

Write a message to the system log.

logger "Deployment completed successfully"

-p, --priority

Set the facility and severity. Format: facility.severity.

logger -p user.err "Something went wrong"
logger -p local0.info "Custom facility message"

-t, --tag

Set the tag (program name) for the log entry.

logger -t myapp "Application started"

-s, --stderr

Output to stderr as well as the system log.

logger -s -t deploy "Starting deployment"

-f, --file

Log the contents of a file.

logger -f /tmp/error_report.txt

-n, --server

Send messages to a remote syslog server.

logger -n logserver.example.com "Remote log message"

--id

Log the PID with the message.

logger --id=$$ -t myapp "Process check"

Scripting pattern

Log script events for debugging.

logger -t backup "Backup started at $(date)"