1

Cant understand, how it logging? Now my log is empty and haproxy doesnt write anything to file. Sometimes it logs some info, Logging works with syslog-ng, if i set in haproxy conf timeout client about 1s, then logging works sometimes. Is logging can affect the recording logs? Sorry. Forgot about config. I'm trying to load balance sybase jdbc.

  • defaults
    • mode tcp
    • timeout connect 5s
    • timeout client 50000
    • timeout server 50000
    • option dontlognull
    • option redispatch
    • retries 3
    • maxconn 4096
  • frontend Sybase
    • bind *:2638
    • mode tcp
    • option tcplog
    • log global
    • log-format [%t]\ from\ %ci:%cp\ to\ %fi:%fp\ %si:%sp\ %s\ %ts\ request_size=%U\ response_size=%B
    • default_backend Sybase
    • backend Sybase
    • mode tcp
    • log global
    • option tcplog
  • balance leastconn
  • server base_1 sybase:2638 check
    • server base_2 sybase:2638 check
3

1 Answer 1

4

To have these messages end up in - for example - /var/log/haproxy.log you will need to do two things:

  • configure your syslog to accept network logs - at least on localhost
  • configure haproxy to send events to 127.0.0.1 on local2/local3 or any such facility

So, your haproxy.cfgs global section would look something like:

global
    log         127.0.0.1 local2 notice
    log         127.0.0.1 local3

While your syslog.conf should look like:

local2.*        /var/log/haproxy
local3.*        /var/log/haproxy-access_log

If you use modern distro with rsyslog, then just create a file called

/etc/rsyslog.d/haproxy.conf

with following contents:

$ModLoad imudp
$UDPServerAddress 127.0.0.1
$UDPServerRun 514

local2.*        /var/log/haproxy
local3.*        /var/log/haproxy-access_log

And after that restart rsyslogd and haproxy.

8
  • I'm using sles, and syslog-ng, i've setup logging in it. Sometimes, logs not writing, or haproxy write log after client dissconected. I dont need rsyslog :) Nov 11, 2014 at 12:57
  • You have to log through syslog instance - wether it's rsyslog, sysklogd or syslog-ng - it's irrelevant. HaProxy will send logs via UDP socket to syslog implementation you use, an you have to set up your syslog to accept and write logs to actual files. If you need help with syslog-ng, I can extend my answer with syslog-ng configuration you need. Nov 11, 2014 at 13:01
  • Here is my settings in syslog-ng - source s_udp { udp(ip(127.0.0.1) port(514)); }; destination d_haproxy { file("/var/log/haproxy"); }; filter f_local0 { facility(local0); }; log { source(s_udp); filter(f_local0); destination(d_haproxy); }; Nov 11, 2014 at 13:04
  • Change your facility from local0 to the one you use in your haproxy.cfg. Also, check if you have iptables set up blocking traffic on firewall set up. Nov 11, 2014 at 13:07
  • Also, it would be good if you can post sanitized configs of both syslog-ng and haproxy in OP. Nov 11, 2014 at 13:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .