LinuxCommandLibrary

logger

TLDR

Log a message

$ logger [message]
copy
Log from stdin
$ echo [message] | logger
copy
Log to remote server
$ echo [message] | logger -n [hostname] -P [port]
copy
Log with custom tag
$ echo [message] | logger -t [tag]
copy
Log with priority
$ echo [message] | logger -p user.warning
copy

SYNOPSIS

logger [options] [message]

DESCRIPTION

logger adds entries to the system log (syslog). It is useful for logging from shell scripts or adding custom messages to system logs for debugging and monitoring.

PARAMETERS

-n, --server HOST

Send to remote syslog server
-P, --port PORT
Remote server port (default: 514)
-t, --tag TAG
Mark messages with tag (default: username)
-p, --priority PRIORITY
Log priority (facility.level, default: user.notice)
-s, --stderr
Also output to stderr
-f, --file FILE
Log contents of file
-i
Include process ID

PRIORITY LEVELS

Facilities: auth, cron, daemon, kern, local0-7, mail, news, syslog, user, uucp
Levels: emerg, alert, crit, err, warning, notice, info, debug

SEE ALSO

Copied to clipboard