0

i just want to save log for backend request and the restarting of haproxy service in haproxy, this is the configuration of my haproxy.


   [appadmin@sltxh5gvt4c rsyslog.d]$ cat /etc/rsyslog.conf

# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
# Save haproxy log
local3.*                     /var/log/haproxylog/haproxy.log
# Save keepalived log
local2.*                     /var/log/keepalived/keepalived.log

++++++++++ this is haproxy.cfg

defaults
  option forwardfor
  log global
  option httplog
  log 127.0.0.1 local3


frontend case3
    bind :80
    mode http
    log global
    option httpclose 
    timeout client 5000
    acl sabrix path_beg -i /sabrix
    acl geolink path_beg -i /axis2
    use_backend sabrix_servers if sabrix
    use_backend us_geolink if geolink
    capture request header Host len 64
    capture request header User-Agent len 128
    capture request header X-Forwarded-For len 100
    capture request header Referer len 200
    capture response header Server len 40
    capture response header Server-ID len 40
    log-format %ci:%cp\ %si:%sp\ %ST\ %r\ %b\ %f\ %bi\

+++++++++++++++++++++++++ haproxy.log

2020-06-14T23:33:36+08:00 localhost haproxy[27891]: 10.12.12.12:42164 -:- 400 <BADREQ> case3 case3 - 
2020-06-14T23:33:42+08:00 localhost haproxy[27891]: 10.12.12.12:42204 -:- 400 <BADREQ> case3 case3 - 
2020-06-14T23:33:48+08:00 localhost haproxy[27891]: 10.12.12.12:42244 -:- 400 <BADREQ> case3 case3 - 

i don't want to save such logs in my haproxy.log, how to change my configuration files ?

thanks

jerrywang
  • 31
  • 5

2 Answers2

0

You can't do this in haproxy, the best way to discard this log lines is with rsyslog.

:msg, contains, "BADREQ" ~

There are more information about discarding unwanted messages in this document.
https://www.rsyslog.com/discarding-unwanted-messages/

This looks similar to this question.
rsyslog filtering and forwarding

Aleksandar
  • 2,442
  • 3
  • 15
  • 24
0

i tried to edit /etc/rsyslog.conf

# ignore BADREQ in haproxy.log
:msg, contains, "BADREQ"  /var/log/haproxylog/haproxy.log

or

# ignore BADREQ in haproxy.log
:msg, contains, "BADREQ"  stop

both don't work.

i check haproxy.cfg, i got the answer, we just need add
option dontlognull

to haproxy.cfg

jerrywang
  • 31
  • 5