haproxy打开日志的方法(ubuntu 12.04):
一、修改haproxy.cfg配置:
global
log 127.0.0.1 local3 err
maxconn 4096
daemon
nbproc 1
/*
注:
log [max_level]
Connections are logged at level "info". Services initialization andservers
going up are logged at level "notice", termination signals are loggedat
"warning", and definitive service termination, as well as loss ofservers are
logged at level "alert". The optional parameter specifies above
what level messages should be sent. Level can take one of these 8 values :
emerg, alert, crit, err, warning, notice, info, debug
For backwards compatibility with versions 1.1.16 and earlier, the default level
value is "debug" if not specified.
Permitted facilities are :
kern, user, mail, daemon, auth, syslog, lpr, news,
uucp, cron, auth2, ftp, ntp, audit, alert, cron2,
local0, local1, local2, local3, local4, local5, local6, local7
According to RFC3164, messages are truncated to 1024 bytes before beingemitted.
Example :
---------
global
log 192.168.2.200 local3
log 127.0.0.1 local4 notice
*/
二、在 /etc/rsyslog.conf中
1、增加:local3.*/var/log/haproxy.log
2、放开注释
# provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514
更改为:
$ModLoad imudp
$UDPServerRun 514
三、核实services文件:(网上好多都说看这个,这个系统默认是打开的)
[root@linux ~]# grep 514 /etc/services
syslog 514/udp
#特别特别注意,你的/etc/services里面必须要存在这一行才行
#如果不存在这一行,你可以手动自行增加的!
四、修改rsyslog的启动设定档,通常在/etc/default/rsyslog内
RSYSLOGD_OPTIONS="-c5"
改为:
RSYSLOGD_OPTIONS="-r -c 5"
五、重启syslog
[root@linux ~]# /etc/init.d/rsyslog restart
看到下面的信息说明rsyslogd已经监听udp 514端口了
[root@linux ~]# netstat -lunp
udp6 0 0 :::514 :::* 30975/rsyslogd