search

Home  >  Q&A  >  body text

The log line in the nginx configuration is commented, but there is still access log output

In my nginx configuration file, the access.log line is commented, but when accessing the project, there are still logs printed out. Where can I control the log? How can I disable nginx's log output?

The configuration is as follows

#user  nobody;
worker_processes  1;
error_log  logs/error.log;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}

http {
    server_names_hash_bucket_size 50;
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    client_max_body_size 1024M;
    keepalive_timeout  65;
    ssi on;
    server {
        listen       80;
        server_name  localhost pytgame.com;
        #charset koi8-r;
        ssi on;    
        autoindex on;    ## 开启目录访问,线上环境记得关闭
       location /{
           root  D:/HBPorject/gw_webresources/WebContent;
           index  index.html;
        }
        #error_page  404              /404.html;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    
}

As can be seen from the above code, the error log lines are not commented

error_log  logs/error.log;

But the access log configuration is commented out:

#access_log  logs/access.log  main;

So the question is, why is this and how can we prohibit nginx from outputting logs.

我想大声告诉你我想大声告诉你2747 days ago592

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-16 17:11:32

    Disable log output

    access_log off;
    error_log off;

    reply
    0
  • Cancelreply