# Custom http-request header not getting logged

**URL:** <https://discourse.haproxy.org/t/custom-http-request-header-not-getting-logged/4299>\
**Category:** Help!\
**Created:** [September 18, 2019, 4:52pm UTC](https://discourse.haproxy.org/t/custom-http-request-header-not-getting-logged/4299 "2019-09-18T16:52:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/abhi/32/965_2.png) [@abhi](https://discourse.haproxy.org/u/abhi)\
**Post date:** [September 18, 2019, 4:52pm UTC](https://discourse.haproxy.org/t/custom-http-request-header-not-getting-logged/4299/1 "2019-09-18T16:52:45Z")

</div>

I have custom header set and it is not getting logged (i.e I am unable to see in the haproxy log)

Here is my configuration

frontend haproxynode  
bind \*:80  
mode http  
log global  
timeout client 60000  
maxconn 50000

```
acl host_abhi hdr_beg(host) -i -f /Users/abpatti/haproxy/test/testing.lst

```

## http-request deny if !host\_abhi

```
http-request add-header validtest %H if host_abhi
http-request add-header invalidtest %H if !host_abhi 
capture request header validtest len 64
capture request header invalidtest len 64
http-request set-header X-Custom-Header %[url]
capture request header X-Custom-Header len 64
log-format %{+Q}o\ %{-Q}ci\ -\ -\ [%T]\ %r\ %ST\ %B\ %cp\ %ms\ %ft\ %b\ %s\ \%TR\ %Tw\ %Tc\ %Tr\ %Tt\ %tsc\ %ac\ %fc\ %bc\ %sc\ %rc\ %sq\ %bq\ %CC\ %CS\ %hrl\ %hsl\ %sslv\
use_backend backendnodel

```

Here is what I see in the log

Sep 18 09:44:57 haproxy[95312]: 127.0.0.1 - - [18/Sep/201]: 16:44:57 +0000] “GET / HTTP/1.1” 200 155 61669 163 “haproxynode” “backendnodel” “127.0.0.1” \0 0 1 1 2 ---- 1 1 0 0 0 0 0 “” “” “” “” “” “”  
Sep 18 09:44:57 haproxy[95312]: 127.0.0.1 - - [18/Sep/201]: 16:44:57 +0000] “GET /favicon.ico HTTP/1.1” 200 155 61669 166 “haproxynode” “backendnodel” “127.0.0.1” \0 0 0 0 127 ---- 1 1 0 0 0 0 0 “” “” “” “” “” “”  
Sep 18 09:44:59 haproxy[95312]: 127.0.0.1 - - [18/Sep/201]: 16:44:59 +0000] “GET / HTTP/1.1” 200 155 61672 843 “haproxynode” “backendnodel” “127.0.0.1” \0 0 0 0 0 ---- 2 2 0 0 0 0 0 “” “” “” “” “” “”  
Sep 18 09:44:59 haproxy[95312]: 127.0.0.1 - - [18/Sep/201]: 16:44:59 +0000] “GET /favicon.ico HTTP/1.1” 200 155 61672 843 “haproxynode” “backendnodel” “127.0.0.1” \0 0 0 1 123 ---- 2 2 0 0 0 0 0 “” “” “” “” “” “”  
Waiting for data… (interrupt to abort)

The reason I say acl is working fine because, on the backend server I am printing the custom headers and I am unable to see the values

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [September 18, 2019, 10:05pm UTC](https://discourse.haproxy.org/t/custom-http-request-header-not-getting-logged/4299/2 "2019-09-18T22:05:35Z")

</div>

You can’t capture a header that haproxy emits itself.

---

<div class="post-metadata">

**Author:** ![abhi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/abhi/32/965_2.png) [@abhi](https://discourse.haproxy.org/u/abhi)\
**Post date:** [September 18, 2019, 10:58pm UTC](https://discourse.haproxy.org/t/custom-http-request-header-not-getting-logged/4299/3 "2019-09-18T22:58:56Z")

</div>

Thanks

Found the solution for the issue.

I had to use http-request capture req.hdr(validtest) len 64

> <https://stackoverflow.com/questions/47228549/log-haproxy-custom-header>
