Open jinhailang opened 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;
local6
syslog-ng
nginx
为了方便查看日志,这里产生两个日志文件:access.log 记录访问日志;error.log 记录程序日志,包括DEBUG,INFO,ERROR 等。
access.log
error.log
修改配置文件 /etc/syslog-ng/syslog-ng.conf,增加如下配置项:
/etc/syslog-ng/syslog-ng.conf
destination d_nginx_err { file("/var/log/nginx/error.log"); }; destination d_nginx_access { file("/var/log/nginx/access.log"); };
filter f_access_nginx { facility(local5); }; filter f_err_nginx { level(debug .. emerg ) and facility(local6); };
执行
log { source(s_src); filter(f_err_nginx); destination(d_nginx_err); }; log { source(s_src); filter(f_access_nginx); destination(d_nginx_access); };
重启 syslog-ng /etc/init.d/syslog-ng restart
/etc/init.d/syslog-ng restart
end.
nginx.conf
配置local6
,这个值稍后还将在syslog-ng
用到 ,更多可选值nginx
,日志数据标记,后面会用来做筛选syslog-ng
端配置为了方便查看日志,这里产生两个日志文件:
access.log
记录访问日志;error.log
记录程序日志,包括DEBUG,INFO,ERROR 等。修改配置文件
/etc/syslog-ng/syslog-ng.conf
,增加如下配置项:执行
重启
syslog-ng
/etc/init.d/syslog-ng restart
end.