Thursday, March 7, 2013

rsyslog

Installation

apt-get install rsyslog

The configuration file is at

/etc/rsyslog.conf

Basic syntax

To define log format.

$template <format name>
, "<format string>"

To filter and select destination.

if <filter logic> then <destination>;<format name>

For the above, it must be in one line, or with line separator "\".

Example :


For the properties used in the template format and in the filter, please check out the online manual : http://linux.die.net/man/5/rsyslog.conf

My testing :


This is the messages directed to the destination specified in the example :


Some additional notes.

If you are seeing the message trailing by #012, put the below into your configuration file. I do not encounter this in Ubuntu, however, I see this in Debian.

$EscapeControlCharactersOnReceive off

If you see your log happened to have the messages claimed to be repeated as below image :


The default configuration file must have this $RepeatedMsgReduction is turned on. Comment out the line with #.

# $RepeatedMsgReduction on

Check this out!