logger

 

We can send messages to rsyslogd (default) and journald from the command line of from scripts with the logger command. Let’s look at some examples:

 

# logs message as “user.notice” to local syslogd
marc:~> logger “This is an error message”
.
# logs message as “local2.warning” to local syslogd
marc:~> logger ­-p local2.warning “Application SDF1 is not running” 
.
# logs message as “user.notice” to local syslogd on a non­default socket
marc:~> logger ­-u /tmp/socket­dR7wDVNh2Y “Application SDF1 failure”
.
# logs message to remote server using UDP and port 514
marc:~> logger -­d -­P 514 ­-n syslogserver “This is an error message”
.
# logs message to remote server using TCP and port 514
marc:~> logger -­t -­P 514 ­-n syslogserver “This is an error message”

 

We can send messages to journald but they have to fit its format or they will be rejected (man systemd.journal­-fields).

<< logrotate                    dmesg >>