Introduction
Syslog-ng is a logging server that collects logs from the network and locally. It has features like core logging capabilities. It is widely used in IT environments for centralized log management, troubleshooting, and compliance reporting. It has wide protocol support (syslog, JSON, and more), basic filtering, parsing, and storage, etc. It's free, open-source, and also has an available commercial edition.
Prerequisites
- Up and runnig ubuntu 24.04 LTS machine.
- Dual-core processor (2 GHz or higher) , 2 GB memory, 30 GB disk space.
- 1 GBPS network card ( This will be minium requirment )
In this blog, We are going to install the syslog-ng logging server on ubuntu 24.04 LTS
Step 1: Run System Update & Upgrade
First we need to update the ubuntu default repository by executing the given command line.
sudo apt-get update && sudo apt-get upgrade -yStep 2: Installing Syslog-ng
By default syslog-ng package avaiable in ubuntu 24.04 LTS, We just need to execute the given command to install the syslog-ng package.
sudo apt-get install syslog-ng -yStep 3: Start the Syslog-ng service
We need to start the syslog-ng service after the installation porcess complete by default we will get service in stop state, Execute the given command to start.
sudo systemctl start syslog-ng.serviceAfter the executing the command syslog-ng service should be up and running.
Step 4: Enable Remote Log Collection
We need to create a configuration file for the syslog-ng server that makes the syslog-ng receiver logging server.
sudo nano /etc/syslog-ng/conf.d/network.confand paste the following configuration.
# Enable TLS
source s_net {
tcp(ip("0.0.0.0") port(514)
#tls( key-file("/home/aftab70/private-key.pem")
# cert-file("/home/aftab70/public-cert.pem")
# peer-verify(optional-untrusted))
);
};
# Log destinations
destination d_logs {
file("/var/log/logs.txt");
};
# Log paths
log {
source(s_net);
destination(d_logs);
};Optional: If you want a secure syslog-ng server with a cert and key, then you need to generate the cert and key by executing the given command.
To create a cert.d directory.
sudo mkdir /etc/syslog-ng/cert.d/To generate the key.
sudo openssl genrsa -out /etc/syslog-ng/cert.d/syslog-ng.key 2048sudo openssl req -new -x509 -key /etc/syslog-ng/cert.d/syslog-ng.key -out /etc/syslog-ng/cert.d/syslog-ng.cert -days 365 -subj "/CN=<TYPEYOURDNSNAME>"Verify and save the file and exit from the nano text editor.
Step 5: Reload Syslog-ng service
We need to reload the syslog-ng service to get it running with the newly added configuration.
sudo systemctl reload syslog-ng.serviceStep 6: Verify Syslog-ng Port with IP
We need to use the netstat command line utility that helps us know syslog-ng serving host local and public IP using the 514 port number.
sudo netstat -plntu | grep 514Step 7: Check Syslog-NG Logs
Step 8: Configure Syslog-NG client with Apache logs
sudo apt-get install apache2 -ysudo systemctl status apache2.servicecurl -I http://localhostStep 9: Install syslog-NG on the Client Side
sudo apt-get install syslog-ng -ysudo nano /etc/syslog-ng/conf.d/apache.confsource s_apache {
file("/var/log/apache2/access.log");
file("/var/log/apache2/error.log");
};
destination d_remote {
tcp("remote_syslog_server_ip" port(514));
};
log {
source(s_apache);
destination(d_remote);
};sudo systemctl restart syslog-ng.serviceStep 10: Validate the Apache Logs in the Syslog-NG server.
tail -f /var/log/logs.txtConclusion
We have successfully installed and set up the syslog-ng logging server on Ubuntu 24.04 LTS. In case you have any queries, let us know by leaving a comment on this blog. We are happy to serve you better as our reader. Thanks again for checking out our blog.














