I would like to get warned by email when some HTTP codes are triggered, so I wanted to dispatch log between different file depending of the request HTTP code. Like that i can put a watchers on those files and then get warned by mail about it.
Furthermore, logs files should be lighter if HTTP code are in separate files, so it will increase my log parser speed.
I tried to find informations on Apache documentation without success, It look like I have to use SetEnvIf
with something like that :
SetEnvIf ??http_code?? 403 403log
CustomLog ${APACHE_LOG_DIR}/403.log vhost_combined env=403log
SetEnvIf ??http_code?? 404 404log
CustomLog ${APACHE_LOG_DIR}/404.log vhost_combined env=404log
SetEnvIf ??http_code?? 406 406log
CustomLog ${APACHE_LOG_DIR}/406.log vhost_combined env=406log
etc ...
Unfortunatly, It seems "http_code" look a like variable doesn't exist in Apache
Q: Is there a way to dispatch access log depending on the HTTP code in Apache ?
Thanks for reading.
SetEnvIf
looks at the request. From the documentation:The HTTP Response Code would come from the response and therefore is not available.
You're making things harder for Apache in order to make things easier for your log parser. Apache would have to hold open multiple extra file handles as well, consuming extra resources.
If performance is a problem you should collect and process your logs on a different host. There you can do all sorts of aggregation, parsing, notifications, and any special reporting that you would like without any effect on your web servers.