RHCSA Rapid Track
In this exercise, you will reconfigure rsyslog to write specific log messages to a new file.
Outcomes
You should be able to configure the rsyslog service to write all log messages with the debug priority to the /var/log/messages-debug log file.
Log in to workstation as student using student as the password.
On workstation, run lab log-configure start to start the exercise.
This script ensures that the environment is setup correctly.
[student@workstation ~]$lab log-configure start
From
workstation, open an SSH session toserveraasstudent.[student@workstation ~]$ssh student@servera...output omitted...[student@servera ~]$Configure
rsyslogonserverato log all messages with thedebugpriority, or higher, for any service into the new/var/log/messages-debuglog file by adding thersyslogconfiguration file/etc/rsyslog.d/debug.conf.Use the sudo -i command to switch to the
rootuser. Specifystudentas the password for thestudentuser if asked while running the sudo -i command.[student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#Create the
/etc/rsyslog.d/debug.conffile with the necessary entries to redirect all log messages having thedebugpriority to/var/log/messages-debug. You may use the vim /etc/rsyslog.d/debug.conf command to create the file with the following content.*.debug /var/log/messages-debug
This configuration line catches syslog messages with any facility and a
debugor above priority level. Thersyslogservice will write the matching messages to the/var/log/messages-debugfile. The wildcard (*) in thefacilityorpriorityfields of the configuration line indicates any facility or priority.Restart the
rsyslogservice.[root@servera ~]#systemctl restart rsyslog
Verify that all the log messages with the
debugpriority appears in the/var/log/messages-debugfile.Use the logger command with the
-poption to generate a log message with theuserfacility and thedebugpriority.[root@servera ~]#logger -p user.debug "Debug Message Test"Use the tail command to view the last ten log messages from the
/var/log/messages-debugfile and confirm 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 student[25416]: Debug Message TestExit both the
rootandstudentusers' shells onserverato return to thestudentuser's shell onworkstation.[root@servera ~]#exitlogout[student@servera ~]$exitlogout Connection to servera closed.[student@workstation ~]$