# Is static access\_log within if-in-location better than dynamic global?

**URL:** <https://www.ruby-forum.com/t/is-static-access-log-within-if-in-location-better-than-dynamic-global/228891>\
**Category:** NGINX\
**Created:** [May 11, 2013, 8:54pm UTC](https://www.ruby-forum.com/t/is-static-access-log-within-if-in-location-better-than-dynamic-global/228891 "2013-05-11T20:54:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Constantine\_ASMure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3ec8ea/32.png) [@Constantine\_ASMure](https://www.ruby-forum.com/u/Constantine_ASMure)\
**Post date:** [May 11, 2013, 8:54pm UTC](https://www.ruby-forum.com/t/is-static-access-log-within-if-in-location-better-than-dynamic-global/228891/1 "2013-05-11T20:54:31Z")

</div>

Hi,

According to [Module ngx\_http\_log\_module](http://nginx.org/r/access_log), the access\_log directive  
cannot be used within an `if` in `server`, only within an `if` in  
`location`.

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,  
Constantine.
