Sub topic 15
Testing Forwarding and Rotation
Assume you can use sudo, edit rsyslog and logrotate files, inspect /var/log, and use basic systemctl commands. Test from a client server and a central receiver. Replace example paths and hostnames with the paths used in your configuration.
Test the configuration before sending logs
First check that rsyslog can parse its configuration:
sudo rsyslogd -N1A successful check reports that the configuration validation completed. Warnings may still appear, so read the output. A syntax error usually includes the file name and line number. Fix errors before restarting rsyslog.
Check the service on both systems:
sudo systemctl status rsyslog.service
sudo systemctl is-active rsyslog.serviceThe second command should print active.
The test path is:
client logger → client rsyslog → network → receiver rsyslog → per-host log fileSend and confirm a test message
On the client, send a message with a distinctive tag:
logger -t demo "test message from $(hostname)"The -t option sets the program tag to demo. If the receiver uses %programname% in its file template, the message should appear in a file such as demo.log.
On the central server, list the received host directories:
sudo find /var/log/remote -maxdepth 2 -type f -printThen inspect the matching file:
sudo tail -n 20 /var/log/remote/*/demo.logConfirm that the message contains the expected client hostname and text. If the file does not exist, check the client rule, the receiver listener, firewall rules, and the receiver's rsyslog status.
You can inspect listening TCP sockets on the receiver with:
sudo ss -ltnp | grep ':514'The receiver should listen on TCP port 514. A listener alone does not prove that messages are accepted or written.
Test logrotate safely
Debug mode reads the configuration and shows what logrotate would do without changing files:
sudo logrotate -d /etc/logrotate.d/remoteLook for the expected file pattern, rotation count, compression setting, and postrotate command. Then force one rotation:
sudo logrotate -f /etc/logrotate.d/remoteInspect the result:
sudo find /var/log/remote -maxdepth 2 -type f -printf '%p\n' | sortYou should see the active .log file and a rotated file, often ending in .1 or .1.gz. With delaycompress, the newest rotated file may remain uncompressed until the next rotation.
| Check | What it proves |
|---|---|
| `rsyslogd -N1` succeeds | rsyslog syntax is valid |
| Test message appears remotely | Forwarding and storage work |
| `logrotate -d` shows expected actions | Rotation rules are read correctly |
| A forced rotation creates a generation | Rotation and file matching work |
Exercise
Exercise
A client accepts the logger command, but no message appears on the central server. Name two checks you should perform before changing the configuration.
Show answer
Validate rsyslog with sudo rsyslogd -N1 and check connectivity, including the receiver listener with sudo ss -ltnp | grep ':514' and the firewall path.