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 example.com 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 *.example.com; 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.
Advertisements