Disabling logging in NGINX can be useful for various reasons, such as reducing disk usage, improving performance, or simply because you don’t need the logs for a particular application. This guide will walk you through the steps to disable access and error logging in NGINX on a Linux system.
In this tutorial you will learn:
- How to disable access logs in NGINX
- How to disable error logs in NGINX
- How to completely disable error logging in NGINX

| Category | Requirements, Conventions or Software Version Used |
|---|---|
| System | Linux-based operating system |
| Software | NGINX |
| Other | Basic command-line knowledge |
| Conventions | # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
How to Disable NGINX Logging on Linux
Disabling NGINX logging involves modifying the NGINX configuration files. Below are detailed steps to disable access and error logging.
- Disable Access Logs: The first step is to disable access logs by modifying the NGINX configuration file.
$ sudo nano /etc/nginx/nginx.conf
In the configuration file, find the
access_logdirective and comment it out by adding a#at the beginning of the line or set it tooff:#access_log /var/log/nginx/access.log; access_log off;
Save the file and exit the editor.
- Disable Error Logs: The next step is to disable error logs in the same configuration file.
$ sudo nano /etc/nginx/nginx.conf
In the configuration file, find the
error_logdirective and comment it out by adding a#at the beginning of the line or set it to/dev/null:#error_log /var/log/nginx/error.log; error_log /dev/null crit;
Setting the error log to
/dev/nullwith thecritlevel means only critical errors will be logged, effectively minimizing the logging. - Completely Disable Error Logging: If you want to completely disable error logging, you can set the
error_logdirective to/dev/nullwithout specifying any log level.$ sudo nano /etc/nginx/nginx.conf
In the configuration file, find the
error_logdirective and set it to/dev/nullwithout any log level:error_log /dev/null;
This configuration will completely disable error logging.
- Restart NGINX: After making changes to the configuration file, you need to restart NGINX to apply the changes.
$ sudo systemctl restart nginx
Restarting NGINX will apply the new settings, and logging will be disabled as specified.
Conclusion
Disabling logging in NGINX is a straightforward process that can help in optimizing system performance and managing disk space. By following the steps outlined above, you can easily disable both access and error logs in your NGINX server configuration.