转载自:https://www.cnblogs.com/diaolanshan/p/7903130.html
haproxy在默认情况下不会记录日志(:(), 除了在haproxy.cfg里面的global段指定日志输出之外,还要配置系统的日志配置(rsyslog), 以Ubuntu14.4LTS为例:
1. vim /etc/haproxy/haproxy.conf
1
2
3
|
global
log 127.0.0.1 local0
chroot
/var/lib/haproxy
|
2. 在/etc/rsyslog.conf有以下的默认配置:
1
2
3
4
5
6
7
8
9
|
#
# Where to place spool and state files
#
$WorkDirectory
/var/spool/rsyslog
#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig
/etc/rsyslog
.d/*.conf
|
意思是会读取/etc/rsyslog.d下面的配置文件,现在为haproxy创建一个:/etc/rsyslog.d/haproxy.conf
1
2
3
4
|
vim
/etc/rsyslog
.d
/haproxy
.conf
$ModLoad imudp
$UDPServerRun 514
local0.*
/var/log/haproxy
.log
|
3. 重启rsyslog和haproxy