修改haproxy的配置文件/etc/haproxy/haproxy.conf,在global设置中设置日志保存方式为syslog本地保存
log 127.0.0.1 local0
centos6以后syslog替换成了rsyslog,故而修改rsyslog的配置,编辑/etc/rsyslog.d/haproxy.conf
-
$ModLoad imudp
-
$UDPServerRun 514
-
$template Haproxy,"%msg%\n"
-
local0.=info -/var/log/haproxy.log;Haproxy
-
local0.notice -/var/log/haproxy-status.log;Haproxy
-
### keep logs in localhost ##
-
local0.* ~
然后重启rsyslog服务
service rsyslog restart
重启haproxy服务
service haproxy restart
然后就能看到haproxy日志了
/var/log/haproxy.log //haproxy的访问日志
/var/log/haproxy-status.log //haproxy的状态日志
参考:
阅读(1394) | 评论(0) | 转发(0) |