HAproxy自定义log

1. 注释配置

注释或者删除default字段中的option tcplog(httplog)字段,我这里选择注释掉,后面测试都没问题在同意删除

defaults
    mode                    tcp
    log                     global
    log 127.0.0.1           local3
    #option                  tcplog
    option                  dontlognull

如果此配置存在,则会报错

[WARNING] 350/150056 (72960) : parsing [/xx/xx/haproxy/etc/haproxy.cfg:25]: 'log-format' overrides previous 'option tcplog' in 'defaults' section.

2. 添加log-format配置

目前这里贴的是测试用的,后面还要根据实际情况在调整

defaults
    ……
    log-format %ci\ -\ %T\ %ST\ %U\ %si\ %cp\ %Th\ %Tw\ %Tc\ %Tt
    ……

3.重启服务使配置生效

这里贴出log-format可用变量的说明,我对原文进行了一点点调整,源地址为:https://blog.csdn.net/chengfei112233/article/details/78983041

变量字段名称描述类型备注
%Bbytes_read从服务器到客户端数字
%CCcaptured_request_cookie(只有模式http)字符串
%CScaptured_response_cookie(只有模式http)字符串
%Hhostname字符串
%HMHTTP method(只有模式http)比如:POST字符串
%HPHTTP request URI without query string(同上)比如:path字符串
%HQHTTP request URI query string(同上)比如:?bar=baz字符串
%HUHTTP request URI(同上)比如:/foo?bar=baz字符串http
%HVHTTP version(同上)比如:HTTP/1.0字符串
%IDunique-id字符串
%STstatus_code数字
%Tgmt_date_timedate
%TaActive time of the request从TR到end数字http
%TcTc数字tcp
%TdTd = Tt - (Tq + Tw + Tc + Tr)数字
%Tllocal_date_timedate
%Thconnection handshake timeSSL, PROXY proto数字tcp
%Tiidle time before the HTTP request(同上)数字
%TqTh + Ti + TR(同上)数字
%TRtime to receive the full request from 1st byte(同上)数字
%TrTr(同上)响应时间数字http
%Tstimestamp数字
%TtTt数字tcp
%TwTw数字tcp
%Ubytes_uploaded从客户端到服务器数字
%acactconn数字
%bbackend_name字符串
%bcbeconn后端并发连接数字
%bibackend_source_ip连接地址IP
%bpbackend_source_port连接地址的端口数字
%bqbackend_queue数字
%ciclient_ip接收地址IP
%cpclient_port接收端口数字
%ffrontend_name字符串
%fcfeconn前端并发连接数字
%fifrontend_ip前端通过地址IP
%fpfrontend_port前端通过端口数字
%ftfrontend_name_transport“〜”后缀为SSL字符串
%lcfrontend_log_counter数字
%hrcaptured_request_headers default style字符串
%hrlcaptured_request_headers CLF style字符串列表
%hscaptured_response_headers default style字符串
%hslcaptured_response_headers CLF style字符串列表
%msaccept date milliseconds用0填充数字
%pidPID数字
%rhttp_request(同上)字符串
%rcretries数字
%rtrequest_counterHTTP req或TCP会话数字
%sserver_name字符串
%scsrv_conn服务器并发连接数字
%siserver_IP目标地址IP
%spserver_port目标地址端口数字
%sqsrv_queue数字
%sslcssl_ciphers(仅限SSL)比如:AES-SHA字符串
%sslvssl_version(仅限SSL)比如:TLSv1字符串
%tdate_time毫秒分辨率date
%trdate_time of HTTP request(只限HTTP模式)datehttp
%trggmt_date_time of start of HTTP request(同上)datehttp
%trllocla_date_time of start of HTTP request(同上)datehttp
%tstermination_state字符串
%tsctermination_state with cookie status(同上)字符串
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值