+3 votes
in Web & Google by (63.4k points)

To disable access_log created by Nginx, I added 'access_log off;' after 'error_log /var/log/nginx/error.log warn;'

access_log off;

error_log /var/log/nginx/error.log warn;

But I am getting error : "access_log" directive is not allowed here in /etc/nginx/nginx.conf"

How to fix it?

1 Answer

+1 vote
by (271k points)
edited by
Best answer

Did you write "access_log off" inside http?  To disable access_log and error_log, you need to have "access_log off" and "error_log off" inside http.

  http {

          access_log off;

          error_log off;


Check out the link to know how to disable writing to access_log and error_log on the CentOS system. https://www.bitsdiscover.com/nginx-reverse-proxy-how-to-disable-writing-to-access_log-and-error_log-on-centos-linux-system/

Related questions