What an rsyslog Configuration Error Means
An rsyslog configuration error occurs when the rsyslogd logging daemon cannot correctly read or apply settings from its configuration files. This causes the service to either fail to start entirely or operate incorrectly—logs are not written, are lost, or are processed improperly.
Typical error messages in systemd logs:
rsyslogd: error: could not load module 'imuxsock'...
rsyslogd: invalid PRI value...
rsyslogd: file '/etc/rsyslog.conf' has invalid line...
The error may appear when attempting to start the service (systemctl start rsyslog), during system reboot, or when dynamically loading a configuration via rsyslogd -f /path/to/config.
Common Causes
- Syntax error in the configuration file — missing brackets, quotes, use of an incorrect operator (e.g.,
:instead of;), or an incorrectly specified module. - Specification of a non-existent module or file — the config contains a line like
module(load="module_name"), but the module is not installed or the file path is incorrect. - Incorrect permissions — the
sysloguser (under which rsyslog runs) lacks permission to read configuration files or write to target log directories (e.g.,/var/log). - Conflict with another logging daemon — for example,
systemd-journaldmay be capturing messages, or another syslog daemon (e.g.,syslog-ng) is using the same socket. - Corrupted configuration file — accidental character deletion, improper copying, or errors when editing with editors that use different line endings.
- Version incompatibility — the configuration was written for an older version of rsyslog, but a newer version is installed where the syntax of certain directives has changed.
Method 1: Validate Configuration Syntax
The quickest way to identify the problem is to check the syntax without starting the service. Rsyslog provides a built-in utility for validation.
- Open a terminal.
- Run the command:
It checks all configuration files specified in the main configuration (typicallyrsyslogd -N1/etc/rsyslog.confand files from/etc/rsyslog.d/). - If the syntax is correct, you will see:
If there are errors, the output will show the line number and file, for example:rsyslogd: End of config validation run. Donersyslogd: error: could not load module 'imuxsock'... (try loading it with module(load=\"imuxsock\")) [try https://www.rsyslog.com/e/2212 ] - Fix the indicated errors in the corresponding files (usually with
sudo nano /etc/rsyslog.conforsudo vim /etc/rsyslog.d/your-config.conf). - After making corrections, run the validation check again.
💡 Tip: If validation passes but rsyslog still fails to start, the issue may be related to permissions or module conflicts. Proceed to the next methods.
Method 2: Analyze systemd Logs for rsyslog
If the service fails on startup, systemd retains its logs. You can view them without running rsyslog.
- Check the service status:
If the service is inactive, the output may contain a brief error message.systemctl status rsyslog - For a detailed view, use journalctl:
Thejournalctl -u rsyslog -b --no-pager-bflag shows logs from the current boot,--no-pageroutputs everything at once. - Look for lines starting with
rsyslogd:orrsyslog:. Common errors:cannot open file— issue with paths or permissions.module does not exist— missing module.syntax error— error in the config.
- Based on the message, fix the configuration or system settings (e.g., install a missing package:
apt-get install rsyslog-imuxsock).
Method 3: Check and Fix Permissions
Rsyslog runs under the syslog user (sometimes rsyslog). If this user cannot read configs or write to log directories, the service will terminate with an error.
- Ensure configuration files are readable:
Permissions should includels -l /etc/rsyslog.conf /etc/rsyslog.d/rfor group or others (e.g.,-rw-r--r--). If not, correct them:sudo chmod 644 /etc/rsyslog.conf sudo chmod 644 /etc/rsyslog.d/*.conf - Check the owner of the log directory:
The owner should bels -ld /var/logroot, and the group should beadmorsyslog. Thesysloguser must have write (w) permission. - If necessary, change the group for the directory:
Caution: Changing permissions onsudo chgrp syslog /var/log sudo chmod g+w /var/log/var/logmay affect other services. It's better to check permissions on specific log files created by rsyslog (e.g.,/var/log/syslog).
Method 4: Restore Default Configuration
If you cannot locate the error or the config is severely corrupted, it's easier to restore the original files.
For Debian/Ubuntu:
- Reinstall the rsyslog package (note: this may overwrite
/etc/rsyslog.conf). First, create a backup:
After reinstalling, compare the old and new configs and manually transfer your necessary settings.sudo cp /etc/rsyslog.conf /etc/rsyslog.conf.backup sudo apt-get install --reinstall rsyslog - Alternatively, copy examples from the documentation:
sudo cp /usr/share/doc/rsyslog/examples/rsyslog.conf /etc/rsyslog.conf
For RHEL/CentOS:
sudo cp /etc/rsyslog.conf /etc/rsyslog.conf.backup
sudo yum reinstall rsyslog
Note: Restoring the default config will reset all your custom settings. Use this only if you don't remember what you changed or the config is unreadable.
Method 5: Disable Conflicting Modules or Daemons
Sometimes rsyslog conflicts with systemd-journald, which by default collects logs into a binary journal. Rsyslog may attempt to read from journald via the imjournal module, but if settings are incorrect, errors occur.
- Check if the
imjournalmodule is loaded in the config:grep -r "imjournal" /etc/rsyslog.conf /etc/rsyslog.d/ - If you do not want to use journald, comment out the line:
And uncomment the classic socket module:#module(load="imjournal")module(load="imuxsock") - Also ensure
systemd-journaldis not listening on the same socket. Check/etc/systemd/journald.conf:
If needed, restart journald:Storage=volatilesudo systemctl restart systemd-journald. - If you want rsyslog to read from journald, verify the
imjournalmodule settings (e.g.,PollingInterval).
Prevention
To avoid rsyslog configuration errors in the future:
- Always validate syntax before applying a configuration. Integrate the
rsyslogd -N1command into your workflow. - Create backups before editing:
sudo cp /etc/rsyslog.conf /etc/rsyslog.conf.$(date +%F). - Use test environments for complex changes (e.g., virtual machines or containers).
- Document changes — leave comments in configs describing what was added and why.
- Avoid manually editing binary files or configs with unclear contents.
- Monitor updates — when upgrading to a new major version of rsyslog, check the official documentation for syntax changes.
- Configure monitoring — add rsyslog service status checks to your monitoring systems (e.g., via
systemctl is-active rsyslog).
These steps will help maintain reliable logging in your Linux system and quickly identify issues.