I'm not sure if this is possible, and haven't had any success yet. I'm trying to log page generation times at the web server level and currently have this working for all requests with mod_log_config and this configuration:

LogFormat "%h %t %>s %b %T %D \"%r\" " timeformat
CustomLog    /var/log/httpd/timing_log "timeformat"

That works, but is logging details for all requests, including static content like images, javascript, css, that I don't really care about.

Is there a way to log requests only if it was passed through PHP? The CustomLog directive has an optional third argument that can look at an environment variable to determine whether or not to log the request. I've tried looking at SetEnvIf to set that appropriately, but haven't come up with anything yet.


  • Are you sure you don't care about the static content? I would be inclined to log everything and filter out what I currently didn't care about at analysis time. Awstats can do this and I'm sure many other stats-analysis packages can do the same.
    – Ben Dunlap
    Aug 26, 2009 at 22:03
  • I'm already running awstats on the regular 'combined' log file. I would like to limit this log to only those requests served by PHP, but that doesn't seem to be available. You can use SetEnvIf to log based on characteristics of the request, but not based on the response (From what I can tell...)
    – Brandon
    Aug 27, 2009 at 20:50

1 Answer 1


I haven't done this, but the Conditional Logging section in the apache manual seems like a good starting point.

  • 1
    That is about what I have been looking for. From what I can tell, you can use SetEnvIf to set an environment variable based on request headers, but not based on any response characteristics. I guess I'm probably stuck filtering those out based on regex's and such in looking through the generated list.
    – Brandon
    Aug 27, 2009 at 20:52

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.