配置HAProxy記錄日志到指定日志文件中
HAProxy配置
#在global配置項定義:
log 127.0.0.1 local{1-7} info #基于syslog記錄日志到指定設備,級別有(err、warning、info、debug)
listen web_port
bind 127.0.0.1:80
mode http
log global #開啟當前web_port的日志功能,默認不記錄日志
server web1 127.0.0.1:8080 check inter 3000 fall 2 rise 5
# systemctl restart haproxy
Rsyslog配置
vim /etc/rsyslog.conf
$ModLoad imudp
$UDPServerRun 514
......
local3.* /var/log/haproxy.log
......
# systemctl restart rsyslog
驗證HAProxy日志
重啟syslog服務并訪問app頁面,然后驗證是否生成日志
# tail -f /var/log/haproxy.log
Aug 14 20:21:06 localhost haproxy[18253]: Connect from 192.168.0.1:3050 to 10.0.0.7:80 (web_host/HTTP)
Aug 14 20:21:06 localhost haproxy[18253]: Connect from 192.168.0.1:3051 to 10.0.0.7:80 (web_host/HTTP)
Aug 14 20:21:06 localhost haproxy[18253]: Connect from 192.168.0.1:3050 to 10.0.0.7:80 (web_host/HTTP)
本文鏈接:http://www.royaladd.com/35261.html
網友評論comments