Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have the following in config file

server {
    listen       80;
    server_name  _;
    access_log  /var/log/nginx/access.log  main;

server {
    listen       80;
    server_name  example.com
    access_log  off;
    error_log off;

But it is still keep logging for example.com virtual host. What am I doing wrong?

share|improve this question

3 Answers 3

You are missing ; after server_name directive. access_log and off are being treated as additional server_names.

share|improve this answer
In addition, error_log off; doesn't turn off error logging. It just logs errors to a file named 'off'. There's no way to completely disable error logging, the closest you can get is error_log /dev/null crit; which is almost the same thing, since no error log will appear. –  kolbyjack Oct 5 '11 at 12:16
Actually, doing access_log off; causes nginx to write the log into file called off. So this is not right answer. –  user965363 Oct 17 '11 at 8:40
Actually, this is right answer. "Using "off" as the only parameter clears all access_log directives for the current level": wiki.nginx.org/HttpLogModule#access_log. It is not true for error_log (as added by @kolbyjack), but I believe question was about access, not error log. It is possible that some very old versions of nginx don't support this. –  rvs Oct 17 '11 at 16:29

Of course you can completely disable logging. Just point the logfiles to /dev/null and be done. ;)

access_log  /dev/null;
error_log /dev/null;
share|improve this answer

server_name _; <- please change to spesific server name

"_" : mean catch-all server

share|improve this answer
Actually, "_" has no special meaning. It is often used for a default server because it's an invalid name according to dns, and shouldn't ever conflict with any real hostname, but server_name _; by itself doesn't make a server a catch-all. The default_server listen flag does. –  kolbyjack Oct 5 '11 at 12:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.