=Start=
缘由:
在使用[r]syslog时,发现了一个比较怪异的问题,日志中有「#012」这样的字符,但是我之前在操作的时候明明没有发送/打印「#012」啊?还有就是,我的换行符哪去了???
正文:
参考解答:
默认情况下 rsyslog 会将”怪异的”字符(ASCII < 32)进行转义,这其中就包括了换行符(\n)、制表符(\t)等符号,如果你不希望rsyslog自动进行转义,可以在配置文件中进行修改。rsyslog by default escapes all weird characters (ASCII < 32), and this include newlines (as well as tabs and others). Simply add this to your rsyslog config to turn this off:
$EscapeControlCharactersOnReceive off |
另一种可选的方法就是——保持syslog的完整性,只在分析日志的时候对特殊字符进行替换。Alternatively, if you want to keep your syslog intact on one line for parsing, you can just replace the characters when viewing the log:
tail -f /var/log/syslog | sed 's/#012/\n\t/g' tail -f /var/log/syslog | perl -pe 's/#012/\n\t/g;' |
参考链接:
- http://stackoverflow.com/questions/5463992/multiline-log-records-in-syslog
- https://lists.debian.org/debian-user/2008/09/msg00136.html
- http://naonao.blog.51cto.com/1135983/1556842
=END=
《“Linux中[r]syslog的#012问题”》 有 1 条评论
使用rsyslog单独保存iptables log日志实践
https://www.jianshu.com/p/ff922a289f94
https://wsgzao.github.io/post/iptables-log/