Log inSign up

Gather the logs of all your servers on one rsyslog host

On the collector, load the imtcp module, listen on TCP 514 (or 6514 with TLS) and write incoming lines to /var/log/remote/HOST/PROGRAM.log through a template. On each sender, add one omfwd action with a disk assisted queue, allow only the sender addresses in the firewall, then prove the path with logger -t demo hello.

Topic: Monitoring and logs · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

What does a central rsyslog server give me?

A single place to read and keep logs, even when the original server is broken, reinstalled or out of disk. If an attacker cleans logs on one box, the copies on the collector stay intact, and searching for an error across several machines becomes one grep.

rsyslog fits this job well because it is already the classic syslog daemon on Ubuntu and on Rocky and Alma, speaks plain TCP and TLS, and buffers to disk when the collector is unreachable. It works on plain files, so it stays light: a 1 or 2 GB plan handles a handful of chatty servers. Logs explain events, while the console Usage graphs tab shows CPU, disk and traffic history next to them. If you later want search and dashboards, rsyslog can feed Graylog or Loki instead of files.

Is rsyslog already installed?

Ubuntu, Rocky Linux and AlmaLinux images ship rsyslog and run it by default. Debian 12 and 13 rely on the systemd journal alone, so install rsyslog there on both the collector and every sender:

# Ubuntu, Debian
sudo apt update
sudo apt install -y rsyslog rsyslog-gnutls

# Rocky Linux 9, AlmaLinux 9
sudo dnf install -y rsyslog rsyslog-gnutls

sudo systemctl enable --now rsyslog
rsyslogd -v

The rsyslog-gnutls package is only needed for the TLS setup later, but it costs nothing to add now. On Debian, rsyslog reads from the journal automatically once installed, so messages from systemd units flow into it as well. If you only need to read logs on a single host, the journalctl guide may be all you need.

How do I set up the collector to receive and sort logs?

Create one drop-in file on the collector. It loads the TCP input, binds it to a dedicated ruleset so remote lines stay out of local files, and builds a file path from the sending host and program name:

sudo nano /etc/rsyslog.d/10-collector.conf
module(load="imtcp")

template(name="RemotePath" type="string"
         string="/var/log/remote/%HOSTNAME%/%PROGRAMNAME%.log")

ruleset(name="fromRemote") {
    action(type="omfile" dynaFile="RemotePath"
           dirCreateMode="0750" fileCreateMode="0640")
}

input(type="imtcp" port="514" ruleset="fromRemote")

Prepare the folder. Ubuntu runs rsyslog as the syslog user, so it needs ownership there; Debian, Rocky and Alma run it as root:

sudo mkdir -p /var/log/remote
sudo chown syslog:adm /var/log/remote    # Ubuntu only
sudo rsyslogd -N1
sudo systemctl restart rsyslog
sudo ss -tlnp | grep ":514 "

rsyslogd -N1 checks the whole configuration and prints any error with file and line. The ss output should show rsyslogd listening on port 514.

How do I open the port only for my own servers?

Never leave the syslog port open to everyone: anyone could fill your disk with fake lines. Allow each sender by address. With UFW on Ubuntu and Debian:

sudo ufw allow from 203.0.113.10 to any port 514 proto tcp
sudo ufw allow from 2001:db8:4f2a::10 to any port 514 proto tcp
sudo ufw status numbered

With firewalld on Rocky and Alma, use a rich rule per sender:

sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" port port="514" protocol="tcp" accept'
sudo firewall-cmd --reload

SELinux already labels TCP 514 and 6514 as syslog ports, so no extra policy is required. More firewall patterns are in the UFW guide and the firewalld guide.

How do I forward logs from each sender without losing lines?

Add a forwarding action with a disk assisted queue, so messages wait on the sender while the collector is down and are delivered once it returns:

sudo nano /etc/rsyslog.d/90-forward.conf
action(type="omfwd" target="198.51.100.24" port="514" protocol="tcp"
       queue.type="LinkedList" queue.filename="fwd_central"
       queue.maxDiskSpace="512m" queue.saveOnShutdown="on"
       action.resumeRetryCount="-1" action.resumeInterval="10")

The queue files go to rsyslog's work directory (/var/spool/rsyslog on most systems, /var/lib/rsyslog on Rocky and Alma). resumeRetryCount="-1" means retry forever instead of dropping messages. Validate and restart, then send a marker line:

sudo rsyslogd -N1
sudo systemctl restart rsyslog
logger -t demo "hello from $(hostname)"

On the collector the line appears in /var/log/remote/SENDERNAME/demo.log. The folder name is the hostname the sender reports, so set clear names first with the hostname guide.

How do I encrypt the traffic with TLS?

Plain TCP is fine inside a firewall rule list, but logs often contain usernames, paths and addresses, so switch to TLS on port 6514 once more than a couple of servers send across the internet. Create a small private CA and one certificate per host (the private CA guide shows the openssl steps), then copy the files to /etc/rsyslog-tls/ on every machine.

On the collector, replace the plain input with a TLS input:

global(DefaultNetstreamDriver="gtls"
       DefaultNetstreamDriverCAFile="/etc/rsyslog-tls/ca.pem"
       DefaultNetstreamDriverCertFile="/etc/rsyslog-tls/logs.pem"
       DefaultNetstreamDriverKeyFile="/etc/rsyslog-tls/logs.key")

module(load="imtcp" StreamDriver.Name="gtls" StreamDriver.Mode="1"
       StreamDriver.AuthMode="x509/name" PermittedPeer=["*.example.net"])

input(type="imtcp" port="6514" ruleset="fromRemote")

On each sender, point the global block at its own certificate and use the TLS options on the action:

action(type="omfwd" target="logs.example.net" port="6514" protocol="tcp"
       StreamDriver="gtls" StreamDriverMode="1"
       StreamDriverAuthMode="x509/name"
       StreamDriverPermittedPeers="logs.example.net"
       queue.type="LinkedList" queue.filename="fwd_central"
       queue.saveOnShutdown="on" action.resumeRetryCount="-1")

Open 6514 in the firewall for the senders, close 514, and test again with logger. Certificate errors are printed by rsyslog itself, so journalctl -u rsyslog -n 30 is the first place to look.

How do I stop the collector from filling its disk?

Rotate the remote files with logrotate. A rule like this keeps two weeks of compressed history per file:

/var/log/remote/*/*.log {
    daily
    rotate 14
    compress
    delaycompress
    missingok
    notifempty
    sharedscripts
    postrotate
        systemctl kill -s HUP rsyslog.service
    endscript
}

Save it as /etc/logrotate.d/remote-logs and dry run it with sudo logrotate -d /etc/logrotate.d/remote-logs. The logrotate guide explains every directive. Also add a disk space alert, for example with Monit, because a noisy sender can still surprise you between rotations.

What should I check when logs do not arrive?

  • Connection: from the sender, run nc -vz 198.51.100.24 514. A timeout points at a firewall rule; a refusal means rsyslog is not listening.
  • Config errors: sudo rsyslogd -N1 on both ends, then journalctl -u rsyslog -n 50.
  • Files missing on the collector: check ownership of /var/log/remote on Ubuntu and look for AppArmor denials with sudo dmesg | grep -i apparmor.
  • Wrong folder names: the sender reports a short or default hostname; fix it and restart rsyslog there.
  • Queue growing: ls -lh /var/spool/rsyslog on the sender shows queued data that waits for the collector.

Keep rsyslog current through normal package updates; restart it after an upgrade and run the logger test again.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A1-2collector for a few servers1 vCPU, 2 GB RAM, 50 GB NVMe$7.20/mo$43.20 for 6 months
A2-4many senders with longer retention2 vCPU, 4 GB RAM, 100 GB NVMe$14.40/mo$43.20 for 3 months

Questions about Central logs with rsyslog

Should I use UDP 514 instead of TCP?

UDP is lighter but silently drops lines when the network or the collector is busy, and it cannot be encrypted. TCP with a disk queue, or TLS on 6514, is the safer default for a central server.

How much disk does a log collector need?

It depends on how chatty the senders are. Measure one day with du -sh /var/log/remote, multiply by your retention and add headroom. Compression usually shrinks text logs a lot.

Can I forward only some logs?

Yes. Wrap the action in a filter, for example if $syslogfacility-text == "authpriv" or $programname == "nginx" then { action(...) }, to send only login and web server lines.

Does the journal get forwarded too?

On Ubuntu, Rocky and Alma, journald passes messages to rsyslog already. On Debian, installing rsyslog makes it read the journal, so systemd service output is forwarded as well.

Can the collector run on the same plan as a website?

For a few servers, yes. Keep logs on a separate path, rotate them and watch disk space. A dedicated small server keeps logs safe when the web server has trouble.

How do I search across all hosts?

Use grep -r "error" /var/log/remote/ for quick checks. For full text search and dashboards, send the stream to Graylog instead.