RHCSA Rapid Track
Reconfigure the rsyslog service to write specific log messages to a new file.
Outcomes
Configure the
rsyslogservice to write all log messages with thedebugpriority to the/var/log/messages-debuglog file.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start logs-syslog
Instructions
Log in to the
serveramachine as thestudentuser and switch to therootuser.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#Configure the
rsyslogservice on theserveramachine to log all messages with thedebugor higher priority, for any service to the new/var/log/messages-debuglog file by changing the/etc/rsyslog.d/debug.confconfiguration file.Create the
/etc/rsyslog.d/debug.conffile with the necessary entries to redirect all log messages with thedebugor higher priority to the/var/log/messages-debuglog file.*.debug /var/log/messages-debug
This configuration line logs syslog messages with any facility and with the
debugor higher priority level:The wildcard (*) in the facility field of the configuration line indicates any facility of log messages.
The
rsyslogservice writes the matching messages to the/var/log/messages-debuglog file.
Restart the
rsyslogservice.[root@servera ~]#
systemctl restart rsyslog
Verify that all the log messages with the
debugpriority appear in the/var/log/messages-debuglog file.Generate a log message with the
usertype and thedebugpriority.[root@servera ~]#
logger -p user.debug "Debug Message Test"View the last ten log messages from the
/var/log/messages-debuglog file, and verify that you see theDebug Message Testmessage among the other log messages.[root@servera ~]#
tail /var/log/messages-debugFeb 13 18:22:38 servera systemd[1]: Stopping System Logging Service... Feb 13 18:22:38 servera rsyslogd[25176]: [origin software="rsyslogd" swVersion="8.37.0-9.el8" x-pid="25176" x-info="http://www.rsyslog.com"] exiting on signal 15. Feb 13 18:22:38 servera systemd[1]: Stopped System Logging Service. Feb 13 18:22:38 servera systemd[1]: Starting System Logging Service... Feb 13 18:22:38 servera rsyslogd[25410]: environment variable TZ is not set, auto correcting this to TZ=/etc/localtime [v8.37.0-9.el8 try http://www.rsyslog.com/e/2442 ] Feb 13 18:22:38 servera systemd[1]: Started System Logging Service. Feb 13 18:22:38 servera rsyslogd[25410]: [origin software="rsyslogd" swVersion="8.37.0-9.el8" x-pid="25410" x-info="http://www.rsyslog.com"] startFeb 13 18:27:58 servera root[25416]: Debug Message TestReturn to the
workstationsystem as thestudentuser.[root@servera ~]#
exitlogout [student@servera ~]$exitlogout Connection to servera closed. [student@workstation ~]$