Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?
share|improve this question

2 Answers 2

up vote 2 down vote accepted

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
share|improve this answer
    
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.

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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