The “logger” command is used to send log messages to the system log or to a specific file.
- About logger : A shell command interface to the syslog system log module
- It comes from “util-linux-ng-2.17.2” package.
- Configuration Files:
- Path: /usr/bin/logger
Examples:
1. To log the message to standard error and system logs
# logger -s “This is a test message” |
2. To log to message to the specified file
# logger -f file “This is a test message” |
3. To log the message with specified priority
# logger -p 1 “This is a test message” |
4. To mark every line with specified tag
# logger -t TAG “This is a test message” |
5. To allow the message to start with a hyphen
# logger — “This is a test message” |
Related Commands: syslog, syslogd