Search code examples
apachelogginghttprequestserverrequest-headers

Logging every request to a certain file


I want to log all request- (and maybe also response-) headers of requests, that are made to a certain file on an Apache server. I have tried a php script, but that only fires when I request it directly. Is there any way to log all the requests on a file that I can specify? (If it does matter: in my case the file I want to log the requests for, is a mp4 file.)


Solution

  • Yes you can set and environmental variable to use for determining logging behavior

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

    The last line will prevent the entries for that URI from logging in common access log. You can omit if you are OK with double logging into both logs.