]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: httpclient: change the default log format to skip duplicate proxy data
authorWilliam Lallemand <wlallemand@haproxy.org>
Thu, 22 Dec 2022 14:13:59 +0000 (15:13 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Thu, 22 Dec 2022 14:13:59 +0000 (15:13 +0100)
The httpclient emits logs in the httplog format, however it still
display the frontend, the backend and the server.

In the case of the httpclient we only need to know that we are using the
httpclient, so the backend and server information are irelevant.
In the case of extra code the name of the proxy can be long and will be
displayed twice which is not useful.

This is the same log-format as the httplog but the %b/%s is now -/- so
the format is still compatible with an httplog parser.

Before:
  <134>Dec 22 15:19:27 haproxy[1013520]: -:- [22/Dec/2022:15:19:27.482] <HTTPCLIENT> <HTTPCLIENT>/<HTTPCLIENT> 2/0/4/6/10 200 848 - - ---- 0/0/0/0/0 0/0 {92.123.236.161} "GET http://r3.o.lencr.org/1234 HTTP/1.1"

After:
  <134>Dec 22 15:19:27 haproxy[1013520]: -:- [22/Dec/2022:15:19:27.482] <HTTPCLIENT> -/- 2/0/4/6/10 200 848 - - ---- 0/0/0/0/0 0/0 {92.123.236.161} "GET http://r3.o.lencr.org/1234 HTTP/1.1"

src/http_client.c

index bd398237e8e0e0226ab23f9d1b697db1ad1cb4ae..338bab31a149d24b4c9024c522d31e37a0ad174f 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <string.h>
 
+static char httpclient_log_format[] = "%ci:%cp [%tr] %ft -/- %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r";
 
 static struct proxy *httpclient_proxy;
 
@@ -1214,7 +1215,7 @@ struct proxy *httpclient_create_proxy(const char *id)
        px->conn_retries = CONN_RETRIES;
        px->timeout.client = TICK_ETERNITY;
        /* The HTTP Client use the "option httplog" with the global log server */
-       px->conf.logformat_string = default_http_log_format;
+       px->conf.logformat_string = httpclient_log_format;
        px->http_needed = 1;
 
        /* clear HTTP server */