【问题标题】:HAProxy log-format directive ignoredHAProxy 日志格式指令被忽略
【发布时间】:2016-05-18 18:12:16
【问题描述】:

我最近升级到 haproxy 1.6.3,并为所有 HTTP/TCP 请求提供了默认的 log-format 指令,如下所示:

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

但是,当我重新启动服务器并开始写入日志条目时,它们是使用 haproxy 的默认 HTTP/TCP 日志格式写入的:

2 月 8 日 14:55:41 localhost haproxy[6770]: 主机 - - [08/Feb/2016:21:55:41 +0000] "POST /path/to/service/1.0 HTTP/1.1" 200 841 “” “” 43359 499 “前端” “后端” “服务器” 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

为什么我的log-format 被忽略了?我在重启时没有收到任何警告或警报。

【问题讨论】:

    标签: logging haproxy


    【解决方案1】:

    即使我在 defaults 部分配置了 log-format 指令,也有一些前端设置了 option tcplogoption httplog clf,它们覆盖了我配置的日志格式。

    haproxy documentation 在这里有点误导:

    该指令指定将用于所有日志的日志格式字符串 由使用这条线通过前端的流量产生。如果 指令用于默认部分,所有后续前端都将使用 相同的日志格式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-16
      • 2013-03-07
      • 2011-04-02
      • 1970-01-01
      • 2017-06-01
      • 1970-01-01
      相关资源
      最近更新 更多