How to disable NGINX logging on Linux system

The default configuration of Nginx webserver logging system is to log both access and error logs for all enabled sites into /var/log/nginx/access.log and /var/log/nginx/error.log respectively. This default behaviour is set by the following directives found within /etc/nginx/nginx.conf configuration file:

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

The above directives simply provide a default location of the log file. Commenting out or removing the above lines will not disable logging on Nginx web server. To globally disable Nginx logging you need to include the following directives into your /etc/nginx/nginx.conf:

access_log off;
error_log off;

The above will disable both access and error logging. To disable nginx logging on per site basis simply include the above directives to any desired site configuration file available in /etc/nginx/sites-enabled. Remember to reload your server every time you make changes to Nginx’s configuration files:

# service nginx reload
 * Reloading nginx configuration nginx

Comments and Discussions
Linux Forum