Your config is correct, but NginX tends to be a little... crazy? with Ifs. Take a look on it's If is Evil wiki page.
Aside from that, instead of trying to disable the log on that condition, try to redirect it to another log, like /var/log/nginx/access_localhost.log and see if it helps (link it to /dev/null if it works, or just truncate each day).
Also remember that access_log diretives (and other directives in NginX) will not be inherited. This is a quote from the NginX mail list (linked from NginX's wiki) about the subject:
There is no "global" logs in nginx,
only "local" ones, either explicitly
defined or inhereted from previous
level.
The access_log directive, as all
array-type directives in nginx
config, will ignore inherited values
if defined at certain level. I.e. in
configuration
http {
access_log log1;
server {
server_name server1;
}
server {
server_name server2;
access_log log2;
...
} }
only server1 will have logging set to
log1, while server2 will have logging
set to log2. If you want server2 to
write log into both log1 and log2 you
should say this explicitly, i.e.
server {
server_name server2;
access_log log1;
access_log log2;
...
}