Central log collection with rsyslog and logrotate
A centralised log collector gives administrators one searchable place for service events and authentication records. During an incident, the team can follow a request across several hosts instead of gathering separate /var/log files by hand, and evidence survives a client rebuild.
Rsyslog collects and forwards events; logrotate manages files on disk. Keep those roles separate, encrypt remote syslog traffic, and test queues, storage and recovery with a pilot before expanding across an estate.
Deployment checklist for central logging
Start with a named collector and a clear source inventory. The site's Linux administration guides can help verify package and service conventions across RHEL, CentOS Stream and Fedora before production changes.
Deployment inventory
- Collector hostname, DNS name, certificate identity and owner
- Clients grouped by site, platform, tier and expected volume
- Allowed source CIDRs for TCP 6514 in firewalls and cloud security groups
- Retention period, storage budget, monitoring and recovery expectations
Collection decisions
- Facilities and files included in the remote syslog stream
- Whether clients retain local copies, and for how long
- TLS certificate validation and trust-chain ownership
- Rules that prevent forwarding loops
A shared collector can support a managed-service team in Sydney, Melbourne and Brisbane, but every client needs a cutover and rollback method.
Preparing hosts and network paths
Install the required packages on the collector and forwarding hosts, then create a restricted directory for received files. On RHEL-family systems:
sudo dnf install -y rsyslog logrotate
sudo systemctl enable --now rsyslog
sudo install -d -o syslog -g syslog -m 0750 /var/log/central
Use the account that actually runs rsyslogd; inspect it with ps -o user,group,comm -C rsyslogd. Certificate private keys must remain readable only by root or the rsyslog service account.
Allow TCP 6514 only from known client CIDRs. Add a firewalld rich rule for each source range, reload it, and mirror the restriction in cloud security groups and network ACLs. Synchronise collector clocks and store timestamps in UTC: Sydney and Melbourne change between AEDT and AEST, while Brisbane remains on AEST, so UTC prevents duplicate wall-clock hours at daylight-saving changes.
Building encrypted rsyslog transport
Use rsyslog's imtcp module with the gtls driver. The server certificate's subject alternative name must match the clients' DNS name, and both hosts need the CA chain. Save this as /etc/rsyslog.d/10-central.conf:
module(load="imtcp")
tls.defaultNetstreamDriverCAFile="/etc/pki/rsyslog/ca.pem"
tls.defaultNetstreamDriverCertFile="/etc/pki/rsyslog/server.pem"
tls.defaultNetstreamDriverKeyFile="/etc/pki/rsyslog/server-key.pem"
template(name="CentralFormat" type="string"
string="[%timegenerated:date-rfc3339%] %HOSTNAME% %syslogtag% %msg:::sp-len%\n")
ruleset(name="central") {
action(type="omfile" file="/var/log/central/%HOSTNAME%.log"
template="CentralFormat" fileCreateMode="0640")
}
input(type="imtcp" port="6514"
StreamDriver.Name="gtls" StreamDriver.Mode="1"
StreamDriver.AuthMode="x509/name" StreamDriver.PermitAnyWhenNoTLS="off"
ruleset="central")
Install the certificates at these paths, validate with rsyslogd -N1 and restart rsyslog. The x509/name setting checks certificate identity, while PermitAnyWhenNoTLS="off" blocks a plaintext fallback. Test the endpoint with openssl s_client before forwarding logs.
Forwarding client logs safely
On each client, add a forwarding action while leaving the existing local logging actions intact. A disk-assisted queue protects events during a short network outage and prevents the collector from blocking local logging.
tls.defaultNetstreamDriverCAFile="/etc/pki/rsyslog/ca.pem"
tls.defaultNetstreamDriverCertFile="/etc/pki/rsyslog/client.pem"
tls.defaultNetstreamDriverKeyFile="/etc/pki/rsyslog/client-key.pem"
action(type="omfwd" target="logs.example.net" port="6514"
Protocol="tcp" StreamDriver="gtls" StreamDriverMode="1"
StreamDriverAuthMode="x509/name" queue.type="LinkedList"
queue.filename="remoteQueue" queue.maxDiskSpace="1g"
queue.saveonshutdown="on" action.resumeRetryCount="-1")
Confirm that systemd-journald has ForwardToSyslog=yes where journal coverage is required, then validate and restart rsyslog. Alert on queue growth and disk use; a persistent queue can conceal a broken collector until the client spool fills. Never install this forwarding action on the collector if it would create a loop.
Rotating collected files with logrotate
Central files need their own rotation policy. Logrotate renames active files, compresses old copies and signals rsyslog to reopen the originals, avoiding the loss window associated with copying an open file.
/var/log/central/*.log {
daily
rotate 14
compress
delaycompress
dateext
dateformat -%Y%m%d
missingok
notifempty
su syslog syslog
create 0640 syslog syslog
sharedscripts
postrotate
systemctl kill -s HUP rsyslog
endscript
}
This example retains fourteen daily rotations. Change the period to meet the organisation's approved schedule, and maintain a separate client-side policy because network delivery does not replace local logrotate. The postrotate reload is important: without it, rsyslog can keep writing to an already renamed file descriptor.
Verifying delivery and handling failures
Use a tagged test event and inspect both ends of the path. These checks expose configuration, certificate and permission errors quickly.
sudo rsyslogd -N1
sudo systemctl restart rsyslog
logger -p local0.notice "central logging test"
sudo tail -F /var/log/central/client01.log
sudo logrotate -d /etc/logrotate.d/central-logs
If the event is missing, inspect journalctl -u rsyslog and the client queue, confirm port 6514 with ss, and compare certificate names and clocks. Monitor both /var/spool/rsyslog and /var/log/central for growth. An end-to-end test also reveals a collector that writes locally but forwards nowhere.
Governing retention in Australian environments
Log records can contain usernames, IP addresses, device identifiers and timestamps. Where the Commonwealth Privacy Act 1988 and Australian Privacy Principles apply, assess whether those records are personal information; relevant state and territory privacy laws may also govern the organisation. The Notifiable Data Breaches scheme may require a documented assessment if a qualifying breach occurs. Limit access, audit reads and align controls with the Australian Signals Directorate's Essential Eight.
Australian enterprise and public-sector estates commonly use RHEL, while CentOS Stream and Fedora appear in migration and training environments. Managed-service teams also handle daily handovers across the country. Keep certificate expiry dates, escalation contacts, restore tests and deletion dates in practical project notes rather than relying on institutional knowledge. Add one pilot client, emit a tagged test event, and confirm it appears in that client's collector file.