About haproxy log

Good day

i am newbie here
just want to ask why my haproxy log shows only few info

sample:
[root@BLoadB log]# tail -F haproxy.log
Apr 28 11:13:54 localhost haproxy[2013]: Proxy t2apps started.
Apr 28 11:13:54 localhost haproxy[2013]: Proxy dtrapps started.
Apr 28 11:13:54 localhost haproxy[2013]: Proxy acpsapps started.
Apr 28 11:13:54 localhost haproxy[2013]: Proxy chopchopapps started.

I just want to see on log with destination IP and client IP address etc…

here is my haproxy config

global
    log         /dev/log local0 info
    log         /dev/log local1 notice
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

##    stats socket /var/lib/haproxy/stats

##    ssl-default-bind-ciphers PROFILE=SYSTEM
##    ssl-default-server-ciphers PROFILE=SYSTEM

defaults
    log                     global
    mode                    http
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

   stats enable
   stats hide-version
   stats realm Haproxy Statistics
   stats uri /haproxy_stats
   stats auth admin:admin


frontend main

    maxconn 20000
    bind 192.168.50.250:80
    use_backend t2apps          if { hdr(host) -i t2apps.haproxy.stp1 }
    use_backend dtrapps         if { hdr(host) -i dtr.haproxy.stp1 }
    use_backend acpsapps        if { hdr(host) -i acps.haproxy.stp1 }

backend t2apps
#    mode http
#    option httplog
    balance     roundrobin
    server t2apps1 172.16.31.249:3000 check
    server t2apps2 172.16.31.248:3000 check

backend dtrapps
#    mode http
#    option httplog
    balance     roundrobin
    server acps1 192.168.50.20:4070 check

Thanks

Especially, the following section seems interesting for you:

However, you should keep in mind that if you’re going to use a UNIX socket for logging and at the same time you are running HAProxy within a chrooted environment—or you let HAProxy create a chroot directory for you by using the chroot configuration directive—then the UNIX socket must be made available within that chroot directory. This can be done in one of two ways.

First, when rsyslog starts up, it can create a new listening socket within the chroot filesystem. Add the following to your HAProxy rsyslog configuration file:

$ModLoad imuxsock
$AddUnixListenSocket /var/lib/haproxy/dev/log

best regards,
Markus

Hello Maeh86

Thanks for your reply

but i still get same output on my 2 log file which is haproxy-traffic.log and haproxy-admin.log

both logfile same output

2logfile
nano /var/log/haproxy-traffic.log


May  4 08:12:11 localhost haproxy[6486]: Proxy acpsapps started.
May  4 08:12:11 localhost haproxy[6486]: Proxy chopchopapps started.
May  4 08:12:11 localhost haproxy[6486]: Proxy no_route started.
May  4 08:24:06 localhost haproxy[6537]: Proxy main started.
May  4 08:24:06 localhost haproxy[6537]: Proxy main started.
May  4 08:24:06 localhost haproxy[6537]: Proxy t2apps started.
May  4 08:24:06 localhost haproxy[6537]: Proxy dtrapps started.
May  4 08:24:06 localhost haproxy[6537]: Proxy acpsapps started.
May  4 08:24:06 localhost haproxy[6537]: Proxy chopchopapps started.
May  4 08:24:06 localhost haproxy[6537]: Proxy no_route started.
May  4 08:25:57 localhost haproxy[6551]: Proxy main started.
May  4 08:25:57 localhost haproxy[6551]: Proxy main started.
May  4 08:25:57 localhost haproxy[6551]: Proxy t2apps started.
May  4 08:25:57 localhost haproxy[6551]: Proxy dtrapps started.
May  4 08:25:57 localhost haproxy[6551]: Proxy acpsapps started.
May  4 08:25:57 localhost haproxy[6551]: Proxy chopchopapps started.

nano /var/loghaproxy-admin.log

May  4 08:24:06 localhost haproxy[6537]: Proxy dtrapps started.
May  4 08:24:06 localhost haproxy[6537]: Proxy acpsapps started.
May  4 08:24:06 localhost haproxy[6537]: Proxy chopchopapps started.
May  4 08:24:06 localhost haproxy[6537]: Proxy no_route started.
May  4 08:25:57 localhost haproxy[6551]: Proxy main started.
May  4 08:25:57 localhost haproxy[6551]: Proxy main started.
May  4 08:25:57 localhost haproxy[6551]: Proxy t2apps started.
May  4 08:25:57 localhost haproxy[6551]: Proxy dtrapps started.
May  4 08:25:57 localhost haproxy[6551]: Proxy acpsapps started.
May  4 08:25:57 localhost haproxy[6551]: Proxy chopchopapps started.

i have modified some in my /etc/haproxy/haproxy.cfg and /etc/rsyslog.d/haproxy.conf

for haproxy.cfg

global
    log         127.0.0.1:514 local0
    chroot      /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user        haproxy
    group       haproxy
    daemon

    stats socket /var/lib/haproxy/stats
    master-worker

defaults
    log                     global
    mode                    http
    timeout connect         5000
    timeout client          50000
    timeout server          50000

   log-format "%ci:%cp [%tr] %ft %b/%s %Th/%Ti/%TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %{+Q}r %[capture.req.hdr(0)]"

   stats enable
   stats hide-version
   stats realm Haproxy Statistics
   stats uri /haproxy_stats
   stats auth admin:admin

frontend main
    log 127.0.0.1 local0 notice
    bind 192.168.50.250:80

    use_backend t2apps          if { hdr(host) -i t2apps.tailinsubic.server }
    use_backend dtrapps         if { hdr(host) -i dtr.tailinsubic.server }
    use_backend acpsapps        if { hdr(host) -i acps.tailinsubic.server }
    use_backend chopchopapps    if { hdr(host) -i chopchop.tailinsubic.server }

backend t2apps
    balance     roundrobin
    server t2apps1 172.16.31.249:3000 check
    server t2apps2 172.16.31.248:3000 check

backend dtrapps
    balance     roundrobin
    server dtr1 172.16.31.241:5083 check
    server dtr2 172.16.31.235:5084 check

backend acpsapps
    balance     roundrobin
    server acps1 192.168.50.20:4070 check

backend chopchopapps
    balance     roundrobin
    server chochop1 172.16.31.241:5084 check
    server chopchop2 172.16.31.235:5083 check

for haproxy.conf

# Collect log with UDP
$ModLoad imudp
$UDPServerAddress 127.0.0.1
$UDPServerRun 514

# Creating separate log files based on the severity
local0.* /var/log/haproxy-traffic.log
local0.notice /var/log/haproxy-admin.log

then i created folder for admin.sock mkdir -p /run/haproxy/

when i restart two service haproxy.service and rsyslog.service it was successfully restarted with no errors

but i still get same output on the two log files.

thanks

Here is my configuration:

/etc/haproxy/haproxy.cfg

global
        log /dev/log   local0 info
        log /dev/log   local1 info
        chroot /var/lib/haproxy
        stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
        stats socket /var/lib/haproxy/stats
        stats timeout 30s
        user haproxy
        group haproxy
        daemon
[...]
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 
[...]

/etc/rsyslog.d/49-haproxy.conf

# 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
:programname, startswith, "haproxy" {
  /var/log/haproxy.log
  stop
}

best regards,
Markus

I suggest you put all your logging configuration into your global/defaults section, more specifically I suggest you don’t reconfigure logging in your main frontend.

When you log via UDP sockets and you don’t know if haproxy doesn’t send the logs or rsyslog doesn’t put them into the right place, tcdpump it and check:

tcpdump -i lo -vvvvs0 udp port 514

You should put option httplog in your defaults.

If you filter syslog message at a specific level, then less important syslog message will not be send.

E.g. if you sepcify “notice” as your max-level, you will never see “info” level message (which is what connections logs have). You you need to make sure that you don’t filter those message, neither in haproxy and rsyslog.