Search This Blog

Friday, October 28, 2016

Add Your Own Custom Log File to RSYSLOG Logging to /var/log/messages in 3 Steps (CentOS 7)

Step 1

Edit /etc/rsyslog.conf and add $ModLoad imfile to the MODULES section at the top. The resultant modules section should look like this:

#### MODULES ####

# The imjournal module bellow is now used as a message source instead of imuxsock.
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imjournal # provides access to the systemd journal
$ModLoad imfile
#$ModLoad imklog # reads kernel messages (the same are read from journald)
#$ModLoad immark  # provides --MARK-- message capability

Step 2

Create one configuration file in /etc/rsyslog.d for each custom log file you wish to be included in /var/log/messages. Each configuration file should look like this example from my addition of a shoutcast server log file to rsyslog. Obviously edit the file for your own log file.

# --
# /etc/rsyslog.d/sc_serv.conf
# --
$InputFileName /home/radio/bin/logs/sc_serv.log
$InputFileTag sc_serv
$InputFileStateFile sc_serv-file1
$InputFileSeverity info
$InputFileFacility local7
$InputFilePersistStateInterval 500

Step 3

Restart rsyslogd and test

# systemctl restart rsyslogd
# tail -f /var/log/messages

and you should see log lines from your external log file included in the /var/log/messages syslog file.

No comments:

Post a Comment

Recommended Products from Amazon