haproxy打印日志到rsyslog

haproxy的配置文件中关于日志的描述仍是:
“`

# 1) configure syslog to accept network log events.  This is done
#    by adding the '-r' option to the SYSLOGD_OPTIONS in
#    /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
#   file. A line like the following can be added to
#   /etc/sysconfig/syslog
#
#    local2.*                       /var/log/haproxy.log

但centos 7中,syslog已经替换为rsyslog。haproxy的log应按如下配置:

  • /etc/rsyslog.conf
    取消注释:
    $ModLoad imudp
    $UDPServerRun 514

    $ModLoad imtcp
    $InputTCPServerRun 514

    增加
    local2.* /var/log/haproxg.log

  • /etc/sysconfig/rsyslog
    SYSLOGD_OPTIONS="-c 2 -r -m 0"
    &~

重启rsyslog haproxy

你可能感兴趣的:(haproxy配置)