title: How do I configure Apache to not log certain cookies?
body: <p>I have Apache running as a proxy and I want to log the cookie string as part of the requests that come through the proxy, but I there are certain cookies I want to exclude since they contain sensitive info. </p>
  
  <p>I know that Apache mod_log_config allows logging the whole cookie string with:</p>
  
  <pre><code>  %{Cookie}i
  </code></pre>
  
  <p>And I can log one particular cookie with:</p>
  
  <pre><code>  %{Foobar}C
  </code></pre>
  
  <p>But I want to log everything <em>except</em> certain cookies if they exist. One possible tactic I tried was to use SetEnvIf combined with %{FOO}e, which prints an environment variable, so something like:</p>
  
  <pre><code>  SetEnvIf = Cookie "(.*?)(Foobar=([^\s;]*;? ?))?(.*)" FILTERED_COOKIES=$1$4
  </code></pre>
  
  <p>and</p>
  
  <pre><code>  %{FILTERED_COOKIES}e
  </code></pre>
  
  <p>This works well if Foobar exists in the cookie string, but if Foobar doesn't exist, if just logs a "-", so I don't get all the other cookies.</p>
  
  <p>It's possible that my regex might be poor, but it seems to work in the matching case, but Apache doesn't seem to handle it right in the non-matching case.</p>
  
  <p>Short of writing a custom Apache mod, is there a way to exclude cookies from being logged?</p>