如何在 nginx 上禁掉 access_log 和 error_log

参考这篇 blog https://www.digitalocean.com/community/tutorials/how-to-configure-logging-and-log-rotation-in-nginx-on-an-ubuntu-vps

如果不想要积累太多 nginx log,直接点禁掉 log,或者 rotate log 见上文。

全局禁掉 error_log 很简单:
error_log /dev/null crit;

禁掉 access_log 不能在全局做,会提示:
nginx: [emerg] "access_log" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:7

所以需要在 server 下搞:
access_log off;

你可能感兴趣的:(如何在 nginx 上禁掉 access_log 和 error_log)