配置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 imudpUDPServerRun 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.yunweipai.com/35261.html
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/52695.html