Using rsyslog with CLI ​

Refer to understanding linux logging for understaning more about syslogs and linux logging

Here we discuss about using rsyslog wih cli, and how it can be used to log messages through CLI and also send priority messages

Log Messages

We can run the command logger to log messages from command line

[root@midas rsyslog.d]# logger "hello this is the message"
[root@midas rsyslog.d]# cat /var/log/messages | grep hello
Sep 29 19:36:38 midas /usr/libexec/gdm-wayland-session[2503]: hello,, this is secured , please dont use if you dont have unauthorized access
Oct  1 21:50:36 midas root[4555]: hello this is the message
[root@midas rsyslog.d]#

Sending rsyslog messages with priority

Priority is a critical part of logging, we need to set the priority of the message basis its severity.

Emergency Priority

Messages with emergency priority are configured such as they get rerouted to console, terminals, and ssh sessions. rsyslog allows such messages to be sent through cli which allows them to be immediately viewed by the other uses.

Run the following command from any terminal

[root@midas rsyslog.d]# logger -p emerg "this is the emergency message"

You will get following message on all the terminals

[centos@midas ~]$
Broadcast message from systemd-journald@midas (Sat 2022-10-01 21:55:43 IST):

root[4607]: this is the emergency message

Message from syslogd@midas at Oct  1 21:55:43 ...
 root[4607]:this is the emergency message

Understanding Linux Logging

Linux operating system is a popular choice for servers, logging of operating system, application, and base system events becomes crucial when hosting large commercial applications, Linux provides, multiple logging options, to help administrators and application support teams to record and track important events and assess the performance of he system and overall setup. here we will try to understand key logging features as made available by Linux OS