InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Apache tutorials

  • AWStats on Ubuntu
  • ApacheBench - load testing
  • Auth to a location or directory
  • Block directory access using htaccess 404
  • Different expire Headers for multiple images
  • Disable directory listing
  • List loaded modules
  • Log Content-Type in access log
  • Log latency and host in apache log
  • Monitoring using mod_status
  • Python to analyze bots in logs
  • Remove php extension from url
  • egrep and access log
  • log custom data in apache access log
  • mod_rewrite
  • top IP list from access log
 
  • Home
  • > Tutorials
  • > Web Development
  • > Apache

How to log page latency and url host in apache log

By admin | Last updated on Jan 13, 2016

Apache log can give you lot of insight into the performance of your site. The default configuration of apache does not log the page serving time and url host name in apache log. Here is the apache configuration which can be used for logging server page serving time and url host name.

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"V:%V D:%D\"" mycombined

This appends an extra field in apache log containing page serving time (after “D:”) and url host field “V:”. The host field is pretty handy if you are hosting multiple sites on same machine. It also helps you identify if there are duplicate pages with www and non-www domains.

Once you have configured the log format (we named it mycombined above) you can use the following config in your virtual host configuration

<VirtualHost *:80>
...
CustomLog "|/usr/sbin/rotatelogs /etc/httpd/logs/myaccess_log.%Y-%m-%d 86400" mycombined
</VirtualHost>

Some points to note

  1. The page serving time is only from server perspective. It does not include the network latency, browser rendering time, etc.
  2. Usually a latency of more than 500 milliseconds points to some problem somewhere.
  3. You should not have presence of both www and non-www in apache log. In case you are using non-www domain for your site, you should redirect www domain to non-www domain.

Suggested posts:

  1. How to customize wordpress image alt tag
  2. How to setup ssl (https) for your site on Ubuntu Linux
  3. Linux – find files containing specific text
  4. PHP sort associative array using custom compare function
  5. Fetch wordpress rss feed as FeedBurner user agent on command line
  6. Block directory access using htaccess 404
  7. Java – array for-each loop
  8. How to prevent your test blog from google crawling but show adsense ads
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Apache, Linux, Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress