1

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

to

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?
The Shurrican
  • 2,230
  • 7
  • 39
  • 58

2 Answers2

2

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
toppledwagon
  • 4,215
  • 24
  • 15
  • 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 02:43
1

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.

http://httpd.apache.org/docs/current/logs.html#multiple

beans
  • 1,550
  • 13
  • 16