Greetings,
My HAProxy 1.8.19 on Debian-9 is logging starts and stops but not traffic. Using the logger tool I can log anything I want to the proper files, so I can’t figure out what’s wrong.
Here is my logging config for rsyslog, saved in /etc/rsyslog.d/haproxy.conf
.
Thanks for any clues!
$ModLoad imudp
$UDPServerAddress 127.0.0.1
$UDPServerRun 514
$FileOwner dialog
$FileGroup dialog
$FileCreateMode 0644
local0.* -/home/dialog/HAPROXY/logs/haproxy-traffic.log
local0.notice -/home/dialog/HAPROXY/logs/haproxy-admin.log
local0.info -/home/dialog/HAPROXY/logs/haproxy-info.log
…and here is the HAProxy config:
global
daemon
maxconn 256
log 127.0.0.1:514 local0
defaults
log global
option tcplog
mode tcp
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend fr_server1
log 127.0.0.1:514 local0
bind 0.0.0.0:8000
default_backend bk_server1
backend bk_server1
log 127.0.0.1:514 local0
server srv1 10.1.1.184:2775 maxconn 2048
From what I know HAProxy logs connections / requests only after they end, therefore you should see a log line only after the connection was closed.
However you could try to use log global
also in the frontend / backend, (although it shouldn’t make a difference). Also check Rsyslog own logs as perhaps it doesn’t understand the syslog protocol version HAProxy is sending (there are two versions RFC-3164 and RFC-5424).
Looking through some of my old HAProxy configuration files, this is how I configured them at that time (it is using Rsyslog):
log /dev/log len 65535 format rfc3164 daemon info err
# do not set log-send-hostname and log-tag
And for Rsyslog:
template(name="haproxy_log_file" type="string"
string="/var/logs/haproxy/%timereported:1:10:date-rfc3339%.log")
template(name="haproxy_log_file_err" type="string"
string="/var/logs/haproxy/%timereported:1:10:date-rfc3339%.err.log")
template(name="haproxy_log_line" type="string"
string="<< %timereported:::date-rfc3339% %syslogseverity-text% >> %msg%\n")
ruleset(name="haproxy_rules") {
action(
type="omfile"
dynaFile="haproxy_log_file"
template="haproxy_log_line"
fileOwner="syslog" fileGroup="haproxy" fileCreateMode="0640"
dirOwner="syslog" dirGroup="haproxy" dirCreateMode="0750" createDirs="off"
sync="off" ioBufferSize="128k" flushOnTXEnd="on" dynaFileCacheSize="2")
if prifilt("*.err") then
action(
type="omfile"
dynaFile="haproxy_log_file_err"
template="haproxy_log_line"
fileOwner="syslog" fileGroup="haproxy" fileCreateMode="0640"
dirOwner="syslog" dirGroup="haproxy" dirCreateMode="0750" createDirs="off"
sync="on" ioBufferSize="128k" flushOnTXEnd="on" dynaFileCacheSize="2")
stop
}
input(type="imuxsock"
socket="/var/lib/haproxy/dev/log"
createPath="on" unlink="on"
ignoreTimestamp="off" useSysTimeStamp="on"
)
if ($programname == "haproxy") then call haproxy_rules
& stop