欢迎各位兄弟 发布技术文章
这里的技术是共享的
关闭 Nginx 的访问日志,可以有下面两种定义方式
把访问日志路径配置为 /dev/null
,/dev/null
是一个黑洞,所有往这里输入的信息都会被吞噬,找不回来的。
直接把访问日志关闭 off
那么这两个哪种好呢? 从性能的角度上看, access_log off;
是比较好的,省去了日志的写入操作
那么,你可能会问,error_log
是否也可以有这两种方式呢?
答案是错的,不想要 Nginx 的错误日志,只有一种办法
如果你写成了
那么就会在 nginx.conf
这个目录生成一个 off
文件,用于存放错误日志,不信你自己可以看看
来自 https://www.twle.cn/t/19362
#关闭或打印到指定目录
access_log off;
error_log /dev/null;
http { 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 /home/log/nginx/error.log main; #access_log /home/log/nginx/access.log; access_log off; error_log /home/log/nginx/logs/error.log; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
来自 https://blog.csdn.net/BlizzardWu/article/details/120564157