Tag: haproxy
-
haproxy配置开启日志(Red Hat Enterprise Linux 8.6)
在默认情况haproxy是不记录日志的;通过配置haproxy.cfg使其记录日志haproxy.cfg:开启haproxy日志记录log 127.0.0.1 local2/etc/rsyslog.conf:利用rsyslog接收日志:去掉这两行的注释: 也有可能是如下形式: 重启rsyslog,查看udp的514端口是否开启: netstat -anlp|grep 514 udp 0 0 0.0.0.0:514 0.0.0.0:* 14592/rsyslogdudp6 0 0 :::514 :::* 14592/rsyslogd systemctl status rsyslog ● rsyslog.service – System Logging ServiceLoaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)Active: active (running) since Mon 2025-02-17 16:07:30 CST; 16h ago tail -f haproxy.log 如果是ubuntu系统,可以参考:
-
ubuntu22.04下haproxy的日志记录到rsyslog配置方法
ubuntu22.04 用apt install haproxy 进行安装后,/etc/haproxy/haproxy.cfg的配置中包含的日志选项: 其中 log /dev/log local0 的意思就是haproxy日志进入到本地日志系统中 (/dev/log).log: 全局的日志配置,local0是日志设备,info 表示日志级别。其中日志级别有 err、warning、info、debug 四种可选。这个配置表示使用 127.0.0.1 上的 rsyslog 服务中的 local0 日志设备,记录日志等级为 info;log 指定收集哪个机器的 log,log 的收集是通过系统工具来实现的,在 centos6 版本之前以 syslog 来收集日志,6版本变为了 rsysylog。这些都是用于收集系统的日志,local0 指定设备,info 表示输出日志的级别,error 级别是在报错的时候才会输出。info 只要有正常信息都会进行输出,生产环境建议设置 为 notice 级别。 安装rsyslog系统,apt install rsyslog,并启动:systemctl start rsyslog, 查看状态: systemctl status rsyslog ,确保没有报错: 编辑 /etc/rsyslog.conf 这个配置文件,在最后加两行: 重启服务: systemctl restart rsyslog 先确保日志文件的权限正确:…