Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
    
What do you intend "main" to do here? – Evan Carroll Dec 14 '15 at 20:40
    
I've flagged this question for removal, because the most upvoted answer has to do with your syntax-error. It has nothing to do with turning off error logging. It has no searchable error messages, and I'm not sure what you're asking or why the provided answers don't solve your problem. – Evan Carroll Dec 14 '15 at 20:42

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

share|improve this answer
7  
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
4  
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
3  
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
    
Is there an advantage to using off instead of /dev/null? If off causes some versions of Nginx write to a file named off, then /dev/null seems like a more universal solution. – Joe Mornin Jan 22 at 23:53

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
    
I use this one too; /dev/null is a real destination; while "off" is a file in some directory – edoceo Dec 13 '15 at 19:30

It should be pretty simple, you could comment the log lines out

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;

and if you do get a crit errors you should do it like this : ´error_log /dev/null crit;´ so it will be :

server {
    listen       80;
    server_name  _;
    access_log  /dev/null crit;
  ...

server {
    listen       80;
    server_name  example.com
    access_log  /dev/null crit;
    error_log /dev/null crit;
share|improve this answer

you can disable access_log by using

access_log off;

but if you want to disable error_log, just don't use error_log option in your conf.

share|improve this answer
2  
How is this adding to the earlier answers? – Dave M Dec 13 '15 at 17:42

Your Answer

 
discard

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.