title: Log HAProxy captured response header in custom format
body: <p>I have an HAProxy configuration with a custom JSON <code>log-format</code>. I want to capture a specific response header and log it.</p>
  
  <p>However, no matter how I try to capture it, I cannot make it appear in the log. </p>
  
  <p>In my log format I use <code>%[capture.res.hdr(0)]</code> but it only comes up as <code>-</code>. I've also tried <code>%[res.hdr(0)]</code> and <code>%[res.hdr(MyHeader)]</code> but they were not valid configuration and HAProxy failed to start.</p>
  
  <p>I've tried capturing using:</p>
  
  <pre><code>capture response header MyHeader len 50
  </code></pre>
  
  <p>But it doesn't work. I also tried:</p>
  
  <pre><code>declare capture response len 50
  http-response capture res.hdr(MyHeader) id 0
  </code></pre>
  
  <p>With no success. The <code>%hs</code> format variable works - all the captured headers are logged in a delimited string. But I want to log the headers separately as JSON properties. </p>
  
  <p>What am I doing wrong?</p>
  
  <p>I'm currently using HAProxy 1.8.</p>