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.

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

So for example:

127.0.0.1 - - [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

1 Answer 1

up vote 2 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

 
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.