How to change rsyslog format

By gr4k

I want to change rsyslog format, so I do:

#!/bin/bash
_file="/etc/rsyslog.conf"
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.

Source:: http://askubuntu.com/questions/870678/how-to-change-rsyslog-format


Leave a Reply