Feature request: support access_log in IF block

According to the documentation, the access_log directive does not
supported the “if in location” context. This however would be very
useful to us and I am sure others.

For example, within on location block I would like to do this:

location {
if (url contains something) {
access_log abc.log main;
}

if (url contains somethingelse) {
access_log xyz.log main;
}

… several more “if” blocks doing the same thing here …
}

Currently the only way to do this (I think?) is to define multiple
location blocks. However due to the complexity of my config files which
already include multiple location blocks as it is with detailed
proxy_pass blocks, this would cause several permutations and the log
file would quickly grow difficult to manage (and error prone as I change
things later and miss changes elsewhere etc).

Thank you for considering this small but useful feature. If there is
already a way to do this please let me know!

On Friday 16 May 2008, Rt Ibmer wrote:

this would cause several permutations and the log file would quickly grow
difficult to manage (and error prone as I change things later and miss
changes elsewhere etc).

Thank you for considering this small but useful feature. If there is
already a way to do this please let me know!

“if (url contains something)” is basically a location directive.
What you want is sublocations/nested locations which are supported but
undocumented, because they don’t work 100% correctly.