Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syslog-ng log template \\011 character

Tags:

syslog-ng

I have a problem with syslog-ng. I want to make syslog-ng to format the logs like below:

template("$YEAR-$MONTH-$DAY\\011$HOUR:$MIN:$SEC\\011$HOST\\011$MSGHDR$MSGONLY\n")

But it logs without the "\". Just "011". Example:

Expected: 2012-11-28\\01116:33:51\\011host_name\\011app_name[26250]: message

Happened: 2012-11-2801116:33:51011host_name011app_name[26250]: message

How to achieve this? Any ideas? :) Thanks in advance ;)

like image 701
0xmtn Avatar asked Nov 12 '22 16:11

0xmtn


1 Answers

The template function appears to accept escaped characters, so you would need to add an extra \ for each one:

template("$YEAR-$MONTH-$DAY\\\\011$HOUR:$MIN:$SEC\\\\011$HOST\\\\011$MSGHDR$MSGONLY\n")
like image 123
klugerama Avatar answered Jan 04 '23 02:01

klugerama