Configuring rsyslog
Configure rsyslog
to include custom organization-specific
behaviors.
You can customize rsyslog
configuration in two ways:
- Edit the
/etc/rsyslog.conf
file. - Create a configuration file and store it in the
/etc/rsyslog.d
directory. You can select this option to prevent custom configurations from being overwritten when system packages are updated.
Some changes are straightforward to implement within the
/etc/rsyslog.conf
file, such as configuring the log for a
specific selector. For example, to change the log for cron
messages
to cron_new
, add the following line:
cron.* /var/log/cron_new
Restart the rsyslog
service for the change to take effect.
Other changes often require more parameter definitions and steps.
For example, you can create a rule that uses TCP to forward messages to another server where system messages are logged. The following steps implement this sample rule:
A new system logging rule has been configured, and now forwards system messages to another server.
To manage the rotation and archival of the correct logs, edit the
/etc/logrotate.d/syslog
configuration file so that it
references each of the log files that are defined in the RULES
section of the /etc/rsyslog.conf
configuration file.
To configure how often the logs are rotated and how many past copies of the logs are
archived, edit the /etc/logrotate.conf
configuration file.
For more information about log rotation, see the logrotate(8)
,
logwatch(8)
, rsyslogd(8)
and
rsyslog.conf(5)
manual pages.