How to Setup Rsyslog Server on Ubuntu 18.04 LTS

Logs are very useful for analyzing and troubleshooting any issues related to system and applications in Linux. By default, all log files are located inside /var/log directory in Linux-based operating systems. There are several types of log files including, cron, kernel, users, security and most of these files are controlled by Rsyslog service.

Rsyslog is a powerful and secure system for log processing. Rsyslog server receives logs over the network from several physical or virtualized servers and monitors the health of different services. With Rsyslog server, you can monitor logs for other servers, network devices, and remote applications from the centralized location.

In this tutorial, we will explain how to configure Rsyslog server on Ubuntu 18.04 server.


  • Two server running Ubuntu 18.04.
  • A static IP address is configured on Rsyslog server machine and is configured on Rsyslog client machine.
  • A root password is configured on both server.

Install Rsyslog

By default, Rsyslog is installed in Ubuntu 18.04 server. If not installed, you can install it by running the following command:

apt-get install rsyslog -y

After installing Rsyslog, you can check the version of Rsyslog with the following command:

rsyslogd -v

You should get the following output:

rsyslogd 8.32.0, compiled with:
	PLATFORM:				x86_64-pc-linux-gnu
	PLATFORM (lsb_release -d):		
	GSSAPI Kerberos 5 support:		Yes
	FEATURE_DEBUG (debug build, slow code):	No
	32bit Atomic operations supported:	Yes
	64bit Atomic operations supported:	Yes
	memory allocator:			system default
	Runtime Instrumentation (slow code):	No
	uuid support:				Yes
	systemd support:			Yes
	Number of Bits in RainerScript integers: 64

See for more information.

You can also check the status of Rsyslog with the following command:

systemctl status rsyslog

You should see the following output:

? rsyslog.service - System Logging Service
   Loaded: loaded (/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-10-22 04:28:55 UTC; 1min 31s ago
     Docs: man:rsyslogd(8)
 Main PID: 724 (rsyslogd)
    Tasks: 4 (limit: 1114)
   CGroup: /system.slice/rsyslog.service
           ??724 /usr/sbin/rsyslogd -n

Oct 22 04:28:53 ubuntu1804 systemd[1]: Starting System Logging Service...
Oct 22 04:28:54 ubuntu1804 rsyslogd[724]: imuxsock: Acquired UNIX socket '/run/systemd/journal/syslog' (fd 3) from systemd.  [v8.32.0]
Oct 22 04:28:54 ubuntu1804 rsyslogd[724]: rsyslogd's groupid changed to 106
Oct 22 04:28:54 ubuntu1804 rsyslogd[724]: rsyslogd's userid changed to 102
Oct 22 04:28:54 ubuntu1804 rsyslogd[724]:  [origin software="rsyslogd" swVersion="8.32.0" x-pid="724" x-info=""] start
Oct 22 04:28:55 ubuntu1804 systemd[1]: Started System Logging Service.

Configure Rsyslog Server

Rsyslog is now installed and running. Next, you will need to configure it to run in a server mode. You can do it by editing the file /etc/rsyslog.conf.

nano /etc/rsyslog.conf

First, you will need to define the protocol either UDP or TCP or both.

To use both UDP and TCP connections at the same time search and uncomment the lines below:

$ModLoad imudp
$UDPServerRun 514
$ModLoad imtcp
$InputTCPServerRun 514

Next, define the specific subnet, IP or domain to limit the access as shown below:

$AllowedSender TCP,,, *
$AllowedSender UDP,,, *

Next, you will need to create a template to tell Rsyslog server how to store incoming syslog messages. Add the following lines just before GLOBAL DIRECTIVES section:

$template remote-incoming-logs, "/var/log/%HOSTNAME%/%PROGRAMNAME%.log" 
*.* ?remote-incoming-logs

Save and close the file when you are finished. Then, check the Rsyslog configuration for any syntax error with the following command:

rsyslogd -f /etc/rsyslog.conf -N1

You should see the following output:

rsyslogd: version 8.32.0, config validation run (level 1), master config /etc/rsyslog.conf
rsyslogd: End of config validation run. Bye.

Finally, restart Rsyslog service with the following command:

systemctl restart rsyslog

Now, verify that Rsyslog is listening on TCP/UDP with the following command:

netstat -4altunp | grep 514

You should get the following output:

tcp        0      0   *               LISTEN      1332/rsyslogd       
udp        0      0   *                           1332/rsyslogd       

Configure Rsyslog Client

Rsyslog server is installed and configured to receive logs from remote hosts.

Now, you will need to configure Rsyslog client to send syslog messages to the remote Rsyslog server.

Log in to the Client machine and open the Rsyslog configuration file as shown below:

nano /etc/rsyslog.conf

Add the following lines at the end of the file:

##Enable sending of logs over UDP add the following line:

*.* @

##Enable sending of logs over TCP add the following line:

*.* @@

##Set disk queue when rsyslog server will be down:

$ActionQueueFileName queue
$ActionQueueMaxDiskSpace 1g
$ActionQueueSaveOnShutdown on
$ActionQueueType LinkedList
$ActionResumeRetryCount -1

Save and close the file. Then, restart Rsyslog server to apply the configuration changes:

systemtcl restart rsyslog

View Client Log

At this point, Rsyslog client is configured to send their log to the Rsyslog server.

Now, log in to the Rsyslog server and check the /var/log directory. You should see the entry with the hostname of your client machines including several log files:

ls /var/log/rsyslog-client/


CRON.log  kernel.log  rsyslogd-2039.log  rsyslogd.log  sudo.log  wpa_supplicant.log


In the above article, we learned how to install and configure the Rsyslog server on Ubuntu 18.04 server. We also learned how to configure Rsyslog client to send logs to the Rsyslog server. Feel free to ask me if you have any questions.

Share this page:

Suggested articles

10 Comment(s)

Add comment


By: Tomas

Do you have to do anything with firewall ? To open ports ? I've seen in other related articles it is recommended to run these commands: ufw allow 514/tcp

ufw allow 514/udp

By: Ian

I am on Ubuntu 18.04.3 LTS and my /etc/rsyslog.conf looks different. 

My "rsyslogd -v" looks the same as above (IE "rsyslogd 8.32.0", etc)


EG for loading the modules and port#s =


# provides UDP syslog reception


input(type="imudp" port="514")

# provides TCP syslog reception


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


This site answers all that - - for rsyslog docs

- the SenderAllowed is legacy and a firewall is the recommended option.

By: Dirk

Ian is right, one has to uncomment the "new" lines: module(... and input(...

Furthermore the upper template example didn't work as long as U ised the line "& ~". Then the config check said something with "STOP"...

By: John

Same here:

Mar 04 14:42:00 ubuntu_server rsyslogd[2496]: error during config processing: STOP is followed by unreachable statements!  [v8.32.0 try ]

The problem must be the "& ~" line.

Does anyone have some clue?

By: Ray

Thanks for the tutorial, it was very helpful. There is one typo on "systemtcl restart rsyslog" should be "systemctl restart rsyslog"

By: Ray

Quick questions is the communication between server-client encrypted? 

By: Torkis Halomoan Daulay

Sir, How I can reset file log in my device (Router and switch cisco) ?because it's been a year running, so I want to reset it to fetch new logsThanks....

By: Mandy Baxter

You've got a minor Type-Oh! in

systemtcl restart rsyslog

By: Kit Cheng

Hello Mr. Jethva,

Thank you for your article.  It was very helpful.  However, I ran into a problem after following your direction.  After I copied the $template directive into the rsyslog.conf file, it is doing what it supposed to do because I can see the new folder created by the hostname.  However, when I try to cd to the folder, I keep getting this "-bash: cd: foldername: Permission denied"

What do I need to do to be able to cd to the folder and see the log files in the folder?

Thank you


By: sdv

systemtcl restart rsyslog, pls change tp systemctl