+3 votes
in Web & Google by (13.1k 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

0 votes
by (20k points)
edited by

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.discoverbits.in/post/nginx-reverse-proxy-how-to-disable-writing-to-access_log-and-error_log-on-centos-linux-system/

...