Central logging with Rsyslog08. Mar '16


Nowadays it's not realistic to observe logs on different machines manually. Instead log messages should be collected at a central logging server and not stored on individual servers at all to reduce disk space usage and disk writes.

Server configuration

Install rsyslog daemon:

apt-get install rsyslog

Create /etc/rsyslog.d/server.conf with following content:

# Provide UDP syslog reception
$ModLoad imudp
$UDPServerRun 514

# Provide TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514

# Use custom filenaming scheme
$template FILENAME,"/var/log/remote/%HOSTNAME%.log"

$PreserveFQDN on

Restart service:

service rsyslog restart

Make sure your network equipment of server firewall won't filter TCP 514 traffic.

Workstation configuration

Again, install rsyslog daemon:

apt-get install rsyslog

Create /etc/rsyslog.d/client.conf and substitute with your log server IP-aadress:

$PreserveFQDN on
$ActionQueueType LinkedList
$ActionQueueFileName srvrfwd
$ActionResumeRetryCount -1
$ActionQueueSaveOnShutdown on
*.* @@

Such configuration makes sure no messages will be lost due to network glitches or reboots.

Finally restart the service:

service rsyslog restart


On server leave following running:

tail -f /var/log/remote/*.log

On workstation:

logger -s "Hello world"
rsyslog syslog