What a Syslog Service Error Means
A syslog service error in Linux indicates that the system logging daemon (typically rsyslog or syslog-ng) has failed to start or has crashed unexpectedly. This is a critical issue because, without a functioning syslog, the system stops recording important events to log files (/var/log/syslog, /var/log/messages, etc.), making it difficult to diagnose other failures.
Typical symptoms:
- The command
systemctl status rsyslogshows a status offailedorinactive. - Errors during startup are visible in the
journalctl -u rsyslogoutput. - Log files in
/var/log/are not being updated. - When attempting to start manually (
sudo systemctl start rsyslog), the service immediately stops.
Common Causes
The error can be triggered by several common problems:
- Corrupted or invalid configuration — A syntax error in
/etc/rsyslog.confor files within/etc/rsyslog.d/following manual editing or a package update. - Port conflict — Another process is already listening on UDP/TCP port 514 (the standard syslog port), preventing the daemon from starting.
- Insufficient disk space — The partition where
/var/logresides is 100% full. - Incorrect permissions — The service lacks permissions to write to the
/var/logdirectory or read configuration files. - SELinux/AppArmor issues — Security policies are blocking the daemon's access to necessary files or sockets.
- Outdated or corrupted package — After a partial package update,
rsyslogmay be incompatible with the current configuration.
Resolution Methods
Method 1: Check Service Status and Restart
Start by diagnosing the current state of the service.
- Check the service status:
systemctl status rsyslog
Pay attention to theActive:line and the last few lines of the log (if errors are present). - View the service's own logs via journald:
journalctl -u rsyslog --no-pager -n 50
This will show the last 50 lines of logs, which may contain clues. - If the service is stopped or in an error state, try restarting it:
sudo systemctl restart rsyslog - Check the status again. If the service started, verify logs are flowing:
tail -f /var/log/syslog
(or/var/log/messageson CentOS/RHEL).
Method 2: Check and Fix Configuration
A syntax error in a configuration file is a frequent cause of failure.
- Validate the syntax of the main config without starting the service:
sudo rsyslogd -N1
If the output containsrsyslogd: error, there is a problem. The command will indicate the line number and description. - Check configs in
/etc/rsyslog.d/:sudo rsyslogd -N1 -f /etc/rsyslog.d/your-config.conf
Replaceyour-config.confwith the name of the suspicious file. - If you find an error, edit the file (
sudo nano /etc/rsyslog.confor viavim). Common issues:- Incorrect directive syntax (e.g., missing space after a selector).
- Use of deprecated modules.
- Invalid paths to log files.
- After fixing, re-check the syntax and restart the service:
sudo rsyslogd -N1 && sudo systemctl restart rsyslog
Method 3: Check Disk Space and Permissions
- Check free space on the partition containing
/var/log:df -h /var/log
If usage is close to 100%, clean up old logs (e.g., compressed*.gzfiles in/var/log/) or expand the partition. - Check permissions on the
/var/logdirectory:ls -ld /var/log
The owner should beroot, and permissions should bedrwxr-xr-x(0755). If permissions differ, correct them:sudo chown root:root /var/log sudo chmod 755 /var/log - Check permissions on specific log files if they already exist:
ls -l /var/log/syslog*
The owner is typicallyrootorsyslog(depending on the distribution). If necessary:sudo chown syslog:adm /var/log/syslog # for Ubuntu/Debian sudo chown root:root /var/log/messages # for CentOS/RHEL
Method 4: Resolve Port Conflict
By default, rsyslog listens on port 514 (UDP and TCP). If another process already uses it, the service will fail to start.
- Find the process listening on port 514:
sudo netstat -tulpn | grep :514
Or withss:sudo ss -tulpn | grep :514 - If the port is occupied, determine if the conflicting process (e.g., an old syslog instance or a custom service) can be stopped. Alternatively, change rsyslog's port:
- Edit
/etc/rsyslog.confand comment out lines containing*.* @or*.* @@(for remote UDP/TCP logging) if they are not needed. - Or change the port in the
imudp/imtcpmodules:
module(load="imudp" port="5140") module(load="imtcp" port="5140")- Reload the config:
sudo systemctl restart rsyslog.
- Edit
Method 5: Update or Reinstall the rsyslog Package
If the problem appeared after a system update, the package may be corrupted or there may be a bug.
- For Ubuntu/Debian:
sudo apt update sudo apt install --reinstall rsyslog - For CentOS/RHEL/Fedora:
sudo yum reinstall rsyslog
Or on Fedora with dnf:sudo dnf reinstall rsyslog - After reinstalling, check the configuration (Method 2) and restart the service.
Method 6: Temporarily Disable SELinux/AppArmor (for Diagnosis)
If you have SELinux (CentOS/RHEL/Fedora) or AppArmor (Ubuntu/Debian) enabled, they may be blocking rsyslog.
- For SELinux, check the logs:
sudo ausearch -m avc -ts recent
If there are entries related to rsyslog, this is a probable cause.
Temporarily set SELinux to permissive mode (not recommended for production):sudo setenforce 0 sudo systemctl restart rsyslog
If the service starts, you need to adjust SELinux policies. Re-enable enforcing:sudo setenforce 1. - For AppArmor, check the profile status:
sudo apparmor_status | grep rsyslog
If the profile is in enforce mode, try switching it to complain:sudo aa-complain /etc/apparmor.d/usr.sbin.rsyslogd sudo systemctl restart rsyslog
Prevention
To avoid a recurring syslog service failure:
- Regularly update your system — Newer rsyslog versions contain fixes for critical vulnerabilities and bugs.
- Do not edit configuration files without a backup — Create a copy before making changes:
sudo cp /etc/rsyslog.conf /etc/rsyslog.conf.bak. - Monitor free disk space — Set up alerts for the
/varpartition exceeding 80% capacity. - Always test your configuration before restarting — Use
rsyslogd -N1after any modifications. - Avoid manually installing packages from untrusted sources — Use only your distribution's official repositories.