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

With a server running Apache and PHP via mod_fcgid, I'd like to log all requests handled by PHP into a separate file so that I can get a better idea of which requests are going through PHP versus being handled directly through the filesystem.

This is a site with some pretty complex rewrite rules in .htaccess (Wordpress with W3 Total Cache), which translates cached PHP requests into static file requests via mod_rewrite, so that cached requests don't even touch the PHP subsystem.

I want to make sure, therefore, that any log customization I do don't get thrown off by the mod_rewrite magic. Just because the request URI ends in .php, for example, doesn't mean that the request will ultimately end up being handled by PHP. I need to key based on whatever happens AFTER all the rewrite rules are applied.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Seems like the most straight-forward and fool proof way to do exactly that would be to including the logging code in every PHP page, probably at the end after calling flush() to send the output of the page, write to the log file, or if setting up locking and doing the file writing from there is too expensive, send something to zeromq (which has a php library I believe in the sample code) or a waiting server of some sort and let that server accept, disconnect, and then lock/write the log. That way if it's called from the PHP it will only log exactly what is run by PHP.

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.