Linux – Rsyslog Log Rotation Using Output Channels

linuxrsyslogUbuntu

I'm running rsyslogd 4.2.0 on Ubuntu. I'm trying to use the output channel feature described here: http://www.rsyslog.com/doc/rsyslog_conf_output.html

Here's the relevant portion of my config:

$outchannel test_rotated,/var/log/test/test.log,1000000,/root/scripts/rotate-test-logs.pl
local0.* :omfile:$test_rotated

But rsyslog refuses to do anything and the /var/log/test/test.log does not even appear.
If I replace those two lines with:

local0.* /var/log/test/test.log

everything works (but file is not rotated automatically of course).

What am I missing?

Best Answer

Ubuntu's man pagea doesn't seem to suggest the syntax

local0.* :omfile:$test_rotated

the site you linked advises -- it says:

Keep  in  mind  that $outchannel just defines a channel with "name". It
does not activate it.  To do so, you must  use  a  selector  line  (see
below).  That selector line includes the channel name plus an $ sign in
front of it. A sample might be:

       *.* $mychannel

Maybe this works:

local0.* $test_rotated

a: It apparently depends on the version of rsyslog you use, hence on the Ubuntu release. It would thus be save to just look at your man page (man rsyslog.conf) or chose the right release in the site I linked.

Related Question