Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

With apache, is it possible to filter out log requests into separate files based on the URL?

So for example: - - [08/Apr/2013:17:06:26 +0100] "GET /this/is/a/url.html HTTP/1.1" 200 67486

Log this specific URL into access_log_first and everything else into another log file?

I did a little research and it seems I could use something like SetEnvIf but not sure how to got about setting it up. Could anyone help out?

I realise this is somewhat a strange requirement and under normal circumstances I would run the URL I need logging on a separate subdomain for example.

share|improve this question
up vote 3 down vote accepted

Yes, SetEnvIf is the right way. Here's an example:

SetEnvIf Request_URI /this/is/a/url.html$ thisurllog
CustomLog thisurl.log common env=thisurllog

If you also want to remove those entries from the regular log, add the following:

CustomLog access.log common env=!thisurllog
share|improve this answer

Your Answer


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.