Pet*_*tah 16 logging syslog haproxy rsyslog
我ppa:vbernat/haproxy-1.5
根据http://haproxy.debian.net/在 ubuntu 14.04 上通过 apt-get 安装了 haproxy 1.5
问题是它登录/var/log/syslog
而不是/var/log/haproxy.log
设置基本上是默认设置:
/etc/haproxy/haproxy.cfg
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL).
ssl-default-bind-ciphers kEECDH+aRSA+AES:kRSA+AES:+AES256:RC4-SHA:!kEDH:!LOW:!EXP:!MD5:!aNULL:!eNULL
ssl-default-bind-options no-sslv3
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
Run Code Online (Sandbox Code Playgroud)
/etc/rsyslog.d
# Create an additional socket in haproxy's chroot in order to allow logging via
# /dev/log to chroot'ed HAProxy processes
$AddUnixListenSocket /var/lib/haproxy/dev/log
# Send HAProxy messages to a dedicated logfile
if $programname startswith 'haproxy' then /var/log/haproxy.log
&~
Run Code Online (Sandbox Code Playgroud)
小智 24
非常棘手。:-) 这是技巧的答案:
注意/etc/rsyslog.d
It 中的文件说 log haproxy into/var/log/haproxy.log
但这不会在不重新启动rsyslog 的情况下生效:
service rsyslog restart
Run Code Online (Sandbox Code Playgroud)
Dan*_* t. 11
默认haproxy.conf
文件在全局设置下提供了明确的说明 - global
. 我在这里复制粘贴给你——
#------------------------------------------------- -------------------- # 全局设置 #------------------------------------------------- -------------------- 全球的 # 要让这些消息最终出现在 /var/log/haproxy.log 中,您将 # 需要: # # 1) 配置syslog 以接受网络日志事件。这个做完了 # 通过在 SYSLOGD_OPTIONS 中添加“-r”选项 # /etc/sysconfig/syslog # #2) 配置local2事件到/var/log/haproxy.log # 文件。可以添加如下一行 # /etc/sysconfig/syslog # #
例如,就我而言,我在 CentOS 6.6 中运行 haproxy,这是同一个 syslogd 服务器,并且必须执行以下操作才能登录到 /var/log/haproxy.log:
将下面的行添加到/etc/rsyslog.d/haproxy.conf
-
local2.* /var/log/haproxy.log
在服务器上启用 syslogd 日志记录 -
# 提供UDP syslog接收 $ModLoad imudp $UDPServerRun 514 $UDPServerAddress 127.0.0.1
小智 6
注释掉这一行 /etc/rsyslog.d
# Send HAProxy messages to a dedicated logfile
if $programname startswith 'haproxy' then /var/log/haproxy.log
Run Code Online (Sandbox Code Playgroud)