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.

We plan to use a tracking pixel to collect some analytics. It would be very helpful to configure a different policy for storing access logs to this pixel (http://ourdomain.com/tracking.png?someParameter=123)

Can Apache be configured to filter and store only the access logs that contain a specific URL pattern on a different location than the main access log? We still want to keep the full access log on the initial partition, with a different retention policy.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You could use mod_setenvif to set an environment variable related to your tracking pixel and then filter the logs using it. something like

SetEnvIf Request_URI "tracking\.png$" tracking
.
.
.

CustomLog logs/access_log common env=!tracking
CustomLog logs/tracking_access_log common env=tracking

If the tracking pixel is requested then the environment variable gets set and the event gets logged to a different file.

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.