jinhailang / blog

技术博客:知其然,知其所以然
https://github.com/jinhailang/blog/issues
60 stars 6 forks source link

nginx 发送日志到 syslog-ng 配置小结 #22

Open jinhailang opened 6 years ago

jinhailang commented 6 years ago

nginx.conf 配置

error_log syslog:server=127.0.0.1,facility=local6 debug;`
access_log syslog:server=127.0.0.1,facility=local5 main;

syslog-ng 端配置

为了方便查看日志,这里产生两个日志文件:access.log 记录访问日志;error.log 记录程序日志,包括DEBUG,INFO,ERROR 等。

修改配置文件 /etc/syslog-ng/syslog-ng.conf,增加如下配置项:

 filter f_access_nginx { facility(local5); };
filter f_err_nginx { level(debug .. emerg ) and facility(local6); };

end.