Nginx disable logging


To disable logging in nginx we need to change values of access_log and error_log to off.

Lets say if you have config file for website in sites-enabled and you want to disable logging for it.

Just open configuration file related to your website and look for access_log & error_log in server block, change their values to off.

server {
listen 80 default;
server_name *;

root /var/www/;
index index.php;
access_log off;
error_log off;

We can also disable logging for specific patters also, lets say for images or for particular path.

To disable logging for images add following code in in server block:

location ~* \.(gif|jpg|png) {
access_log off;

To disable logging for particular path(here I am blocking /images/):

location ^~ /images/ {
access_log off;

After doing any changes in your site nginx conf, just restart nginx and test.
After restarting nginx logging should be disabled.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s