I would like to log the %D and %O log format strings in apache 2.

They are the time taken to serve a request in microseconds and the total bytes sent.

This is useful to generate stats of the server file serving speeds and see whether connectivity to certain IP segments may have trouble. I also plan on doing some load scaling based on the metrics. I also changed to daily logfile extension and daily log for better parsing.

Unfortunately none of the standard log formats seems to include those two values. Or is there one?

I would really like to keep the same log and keep it compliable to awstats, webalizer or various other tools that may arise.

So if i just change

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined


LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %D" vhost_combined

is it likely that usual tooks will still work well? I think i once heard that there is some sort of convention for webserver log files that you can change the format as long as you only append stuff in the end.

  • Can anyone confirm/disprove this?
  • Do you thing this is generally a good idea? Should the results be accurate?
  • Do you know of some alternative method that may work easier? Some sort of iptables logging or something?

I'm not sure if that will work or not, but I'd go for something a bit different. Setup another LogFormat and CustomLog just for your metrics gathering.

LogFormat "%O %D" metrics
CustomLog "|/usr/local/bin/gather_metrics" metrics
  • wow i can pipe it to a program that gathers my metrics! this is HUGE! did not know that. this leverages all my parsing stuff i can directly pipe into database... – The Shurrican Feb 15 '11 at 2:43

I'm fairly confident that the average log parser will do just fine if you only append values to the end of the line.

Apache will let you output to multiple logs as well. If you're worried about your standard log format, just let it be and mix up an additional custom format to do exactly what you need. Log to both.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.