As per the graylog2 docs, I need to add this line to my rsyslog.conf:
$template GRAYLOGRFC5424,"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msg% \n"
I'm doing it programmatically when I spin up a server, so the command I've got going currently is:
sudo sh -c 'echo "\$template GRAYLOGRFC5424,\"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msg% \\\n\"" >> rsyslog.conf'
I'm escaping the dollar sign, both double quotes, and the backslash before the n. However, \n
and \\n
both write an actual newline to the file, but \\\n
writes \n
correctly. Why doesn't \\n
work?
bash
, the behaviour is withsh
. If you dosudo bash -c ...
, you'll get different results. – muru Oct 06 '14 at 16:52