2019-06-10 nginx将日志保存到syslog服务器

2019-06-10  本文已影响0人  张大志的博客
[root@VM_0_3_centos nginx]# vim /etc/rsyslog.conf   #修改syslog服务器的配置
# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
local6.*                                                /var/log/nginx/nginx.log  #表示local6设施的所有级别的日志都保存到/var/log/nginx/nginx.log文件中
systemctl restart rsyslog.service 
server {
    listen       80;
    server_name  syslog.zhangdazhi.com;

    access_log    syslog:server=127.0.0.1:514,facility=local6,nohostname,tag=nginx,severity=info main;  #severity=info是定义日志级别为info

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
}
nginx -s reload
curl -I http://syslog.zhangdazhi.com/
发现日志文件保存到了/var/log/nginx/nginx.log中
上一篇下一篇

猜你喜欢

热点阅读