Kyle February 2016

HAProxy log-format directive ignored

I've recently upgraded to haproxy 1.6.3, and I've provided a default log-format directive for all HTTP/TCP requests as follows:

defaults
    log-format %hr\ %ST\ %B\ %Ts
    log     global
    mode    http
    option  dontlognull
    retries 3
    option redispatch
    option http-server-close
    maxconn 2000
    timeout client 3600s
    timeout server 3600s
    timeout connect 5s
    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

However, when I restart the server and log entries begin to be written, they are written using haproxy's default HTTP/TCP log formats:

Feb 8 14:55:41 localhost haproxy[6770]: host - - [08/Feb/2016:21:55:41 +0000] "POST /path/to/service/1.0 HTTP/1.1" 200 841 "" "" 43359 499 "frontend" "backend" "server" 0 0 0 22 22 ---- 0 0 0 0 0 0 0 "" ""

Feb 8 14:54:05 localhost haproxy[6771]: host:port [08/Feb/2016:14:54:05.469] frontend backend 1/0/4 147 -- 0/0/0/0/0 0/0

Why is my log-format being ignored? I receive no warnings or alerts on restart.

Answers


Kyle February 2016

Even though I had configured a log-format directive in the defaults section, there were some frontends that had set option tcplog and option httplog clf which were overriding the log format I had configured.

The haproxy documentation is a bit misleading here:

This directive specifies the log format string that will be used for all logs resulting from traffic passing through the frontend using this line. If the directive is used in a defaults section, all subsequent frontends will use the same log format.

Post Status

Asked in February 2016
Viewed 2,446 times
Voted 8
Answered 1 times

Search




Leave an answer