is static access_log within if-in-location better than dynamic global?

Constantine A. Murenin cnst++ at
Sat May 11 18:53:48 UTC 2013


According to, the access_log directive 
cannot be used within an `if` in `server`, only within an `if` in 

Indeed, it doesn't actually work within an `if` directly within 
`server`, but variables can be used to seemingly achieve identical 
result.  Or is it?

Use of variables is documented to result in repeated open/close of the 
log-files, potentially alleviated by a cache that is turned off by default.

As such, if I only want to have three `access_log` files in total, and 
most of the requests in question are served from a single `location`, 
would I be much better off in using `access_log` within an "if in 
location" a couple of times, or using a single global `access_log` with 
a single variable that could have only a few possible values, through 
global `if`s, potentially with `open_log_file_cache`?

I guess using `access_log` without variables within "if in location" 
would be much better, but I just want to confirm that it's the case.

Best regards,

More information about the nginx mailing list