BLOG.TIGABEATS.COM

A shrine where thoughts, ideas and random stuff is preserved

Extend Apache log to allow session tracking and response time logging

I used the following Configuration for httpd.conf to start logging Sessionkeys, Response times in seconds and also in microseconds, because if you are measuring performance then just seconds are not enough, however you will still need to do some work if you need to convert microseconds to milliseconds.
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{JSESSIONID}C\" \"rt_sec:%T\" \"rt_microsec:%D\" " combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# JSessionID
LogFormat "%{JSESSIONID}C" jsessionid
#Request time in seconds
LogFormat "\"sec:%T\"" rt_sec
#Request time in microsec (1000000 microsec = 1 sec)
LogFormat "\"sec:%D\"" rt_microsec

# "combinedio" includes actual counts of actual bytes received (%I) and sent (%O); this
# requires the mod_logio module to be loaded.
#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

The log entries should now look like:

172.17.xxx.xxx - - [01/May/2012:12:10:25 +0200] "GET /static/javascript/jquery.ui.datepicker-nl.js HTTP/1.1" 200 492 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0.1) Gecko/20100101 Firefox/9.0.1" "n8ls9F1RVNCdmbK7e6LNLg__.NLATGAPAG02_slot4" "rt_sec:0" "rt_microsec:160"

This information can now be used to do Session tracking, response time statistics in logs using for example “Splunk” and or good old bash / perl

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy this password:

* Type or paste password here:

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>