How to change rsyslog format

By gr4k

I want to change rsyslog format, so I do:

after_line='$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat'
syslog_format='$template precise,"%syslogpriority%,%timegenerated%,%HOSTNAME%,%syslogtag%,%msg%n"'
add_config='$ActionFileDefaultTemplate precise'
sed -i """s/$after_line/$syslog_formatn$add_config/""" $_file

But Im getting

$template precise,"%syslogpriority%,%timegenerated%,%HOSTNAME%,%syslogtag%,%msg%
$ActionFileDefaultTemplate precise

instead of what i want and correct syntax is:

$template precise,"%syslogpriority%,%timegenerated%,%HOSTNAME%,%syslogtag%,%msg%n"
$ActionFileDefaultTemplate precise

So the problem is in n – new line symbol is inserted as new line, not just like a symbol, as I want.


Leave a Reply