# Cookie information in log file

**URL:** <https://www.ruby-forum.com/t/cookie-information-in-log-file/140862>\
**Category:** NGINX\
**Created:** [June 19, 2008, 10:15am UTC](https://www.ruby-forum.com/t/cookie-information-in-log-file/140862 "2008-06-19T10:15:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebastian\_Geib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8c91f0/32.png) [@Sebastian\_Geib](https://www.ruby-forum.com/u/Sebastian_Geib)\
**Post date:** [June 19, 2008, 10:15am UTC](https://www.ruby-forum.com/t/cookie-information-in-log-file/140862/1 "2008-06-19T10:15:41Z")

</div>

Hi everyone,

Hopefully someone here can help me with an issue I am currently facing  
regarding logging in nginx.

We have a customer who uses Google Urchin, the commercial version of  
Google analytics. This tracker needs the cookie information in the last  
field of any given line in the log file. Apparently Apache is able to  
put that information in there from what the Google Urchin help pages  
say:  
[https://secure.urchin.com/helpwiki/en/UTM\_Quick-Install\_(Apache)?highlight=(utm)](https://secure.urchin.com/helpwiki/en/UTM_Quick-Install_%28Apache%29?highlight=%28utm%29)

At the moment I am using the following log format for our nginx servers:  
log\_format main  
'$remote\_addr - $remote\_user [$time\_local] ’  
'“$request” $status $body\_bytes\_sent ’  
'“$http\_referer” “$http\_user\_agent” ’  
‘“$http\_x\_forwarded\_for”’;

In the wiki on codemongers I couldn’t find something regarding this  
cookie information and also Google wasn’t very helpful.

Is there something like $http\_cookie which I could simply append to my  
current log format that would bring the same functionality as the log  
format Google describes for Apache?

Thank you in advance for any hints.

Sebastian

---

<div class="post-metadata">

**Author:** ![Sebastian\_Geib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8c91f0/32.png) [@Sebastian\_Geib](https://www.ruby-forum.com/u/Sebastian_Geib)\
**Post date:** [June 19, 2008, 11:28am UTC](https://www.ruby-forum.com/t/cookie-information-in-log-file/140862/2 "2008-06-19T11:28:41Z")

</div>

Hello!

On Thu, Jun 19, 2008 at 10:05:50AM +0200, Sebastian Geib wrote:

> [https://secure.urchin.com/helpwiki/en/UTM\_Quick-Install\_(Apache)?highlight=(utm)](https://secure.urchin.com/helpwiki/en/UTM_Quick-Install_%28Apache%29?highlight=%28utm%29)
> 
> Is there something like $http\_cookie which I could simply append to my  
> current log format that would bring the same functionality as the log  
> format Google describes for Apache?

[http://wiki.codemongers.com/NginxHttpCoreModule#variables](http://wiki.codemongers.com/NginxHttpCoreModule#variables)

All http headers have their $http\_\* counterparts, and $http\_cookie is  
here too.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Sebastian\_Geib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8c91f0/32.png) [@Sebastian\_Geib](https://www.ruby-forum.com/u/Sebastian_Geib)\
**Post date:** [June 19, 2008, 11:52am UTC](https://www.ruby-forum.com/t/cookie-information-in-log-file/140862/3 "2008-06-19T11:52:54Z")

</div>

Hi Maxim,

Maxim D. schrieb:

> > Is there something like $http\_cookie which I could simply append to  
> > my current log format that would bring the same functionality as the  
> > log format Google describes for Apache?
> 
> [http://wiki.codemongers.com/NginxHttpCoreModule#variables](http://wiki.codemongers.com/NginxHttpCoreModule#variables)
> 
> All http headers have their $http\_\* counterparts, and $http\_cookie is  
> here too.  
> Thank you for you fast response. Apparently I was looking in the wrong  
> place. Now that looks much better in the log files.

Sebastian

---

<div class="post-metadata">

**Author:** ![Sebastian\_Geib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8c91f0/32.png) [@Sebastian\_Geib](https://www.ruby-forum.com/u/Sebastian_Geib)\
**Post date:** [June 19, 2008, 5:30pm UTC](https://www.ruby-forum.com/t/cookie-information-in-log-file/140862/4 "2008-06-19T17:30:53Z")

</div>

This is the log format we using with our urchin 6 setup

log\_format urchin ‘$remote\_addr $http\_host - [$time\_local] “$request”  
$status $body\_bytes\_sent “$http\_referer” “$http\_user\_agent”  
“$http\_cookie”’;

Cheers

Dave
