新行在syslog-ng中被删除

时间:2021-07-13 22:02:15

We have implemented centralised logging using syslog-ng on our load balanced servers. The history of that setup can be seen here: How do I set up PHP Logging to go to a remote server? .
It's working fine but the newlines are getting stripped at the destination. Is there any way to keep the newlines intact? Here's our config:

我们在负载平衡服务器上使用syslog-ng实现了集中式日志记录。可以在此处查看该设置的历史记录:如何设置PHP日志记录以转到远程服务器? 。它工作正常,但新线在目的地被剥离。有没有办法保持新线完好无损?这是我们的配置:

Source

资源

destination php { tcp("server.com" port(xxxx)); };  
log { source(s_all); filter(f_php); destination(php); };  
filter f_php { facility(user); };  

Destination

目的地

destination d_php { file("$PROGRAM" owner(www-data) group(www-data) perm(0644)); };  
filter f_php { program("^\/var\/log\/"); };  
log { source(s_all); filter(f_php); destination(d_php); flags(final); };  

1 个解决方案

#1


0  

You can change the syslog template format for the destination and manually add the newline at the end. For example, here's a template I use for one of my customized syslog-ng streams. I change the date format (to be more easily parsed by a script). Notice the "\n" at the end.

您可以更改目标的syslog模板格式,并在末尾手动添加换行符。例如,这是我用于我的一个自定义syslog-ng流的模板。我更改了日期格式(更容易通过脚本解析)。注意最后的“\ n”。

file("$PROGRAM"
        template("$R_ISODATE $HOST_FROM $MSGHDR$MSG\n")
        template_escape(no)
);

See the syslog-ng docs for information on the various $VARS you can use.

有关可以使用的各种$ VARS的信息,请参阅syslog-ng文档。

#1


0  

You can change the syslog template format for the destination and manually add the newline at the end. For example, here's a template I use for one of my customized syslog-ng streams. I change the date format (to be more easily parsed by a script). Notice the "\n" at the end.

您可以更改目标的syslog模板格式,并在末尾手动添加换行符。例如,这是我用于我的一个自定义syslog-ng流的模板。我更改了日期格式(更容易通过脚本解析)。注意最后的“\ n”。

file("$PROGRAM"
        template("$R_ISODATE $HOST_FROM $MSGHDR$MSG\n")
        template_escape(no)
);

See the syslog-ng docs for information on the various $VARS you can use.

有关可以使用的各种$ VARS的信息,请参阅syslog-ng文档。