5

I am using rsyslogd and I want to put messages into custom log files based on their content (using a template) as well as use a custom file format (using a template). The rsyslog documentation provides good information on how to create a template and apply it based on the contents/facility/etc. of a message, but does not show how to use apply multiple templates to a single message.

1 Answer 1

5

After much searching, I found an example on this stack overflow answer of using multiple templates on a single message, but since that question was on a different topic, I thought this was worth its own question.

The solution is as easy as the example below (copied from the answer linked above):

$template MsgFormat,"%msg%\n"
$template ApacheRemoteCustom,"/var/log/manager/access.log"
if $syslogfacility-text == 'local6' and $programname == 'apache' then -?ApacheRemoteCustom;MsgFormat

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.