How to add recently set cookies to nginx's access log

Posted by etoleb on Server Fault See other posts from Server Fault or by etoleb
Published on 2011-01-18T00:18:43Z Indexed on 2011/11/14 9:57 UTC
Read the original article Hit count: 205

Filed under:
|
|

I'd like to include cookie data in an nginx access log like so:

(simplified example)

log_format foo '$remote_addr "$request" $cookie_bar';
access_log /var/log/nginx/access.log foo;

This works great on requests that already have a cookie "bar", but for the first request to my server nginx will report "-" as the value of "bar".

It seems like my problem is that nginx is looking at the request headers for the cookie value. Is there a way check for a Set-Cookie in the response and use that as a fallback?

© Server Fault or respective owner

Related posts about nginx

Related posts about log-files