nginx 配置中日志行被注释,却依然还有访问日志输出

浏览:55日期:2022-07-25

问题描述

我的nginx配置文件中,access.log行是被注释的,但是在访问项目的时候,依然有日志打印出来,请问在哪里控制日志呢,怎么禁止nginx的日志输出。

配置如下

#user nobody;worker_processes 1;error_log logs/error.log;#pidlogs/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; sendfileon; #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;} } }

从上面代码可以看出来,错误日志的行是没有被注释的

error_log logs/error.log;

但是访问日志的配置是被注释掉的:

#access_log logs/access.log main;

所以问题是,这是为什么呢,怎么才能禁止nginx输出日志。

问题解答

回答1:

禁止日志输出

access_log off;error_log off;

相关文章: