I compiled the nginx on Ubuntu myself. I start my nginx with -c nginx.conf parameter. In my nginx.conf file, I try to turn off error log with but failed.
error_log /dev/null crit;
Still got the error message: nginx: [alert] could not open error log file: open() "/usr/nginx/logs/error.log" failed (2: No such file or directory)
How could I turn off this log or change its location?
If you wish to turn off the Nginx error logs completely, you need to change the line to : error_log /dev/null crit; This will completely turn off the Nginx error logs on your server.
Nginx writes the information in the different severity levels debug , info , notice , warn , error , alert , and emerg to the logs. By default, the Nginx access log is located at /var/log/nginx/access. log and the error log is located at /var/log/nginx/error.
Enabling the error log However, if this is not the case, you can enable it manually in the relevant NGINX configuration file (either at the http , server , or location levels) using the error_log directive. error_log /var/log/nginx/error. log; The error_log directive can take two parameters.
NGINX writes information about encountered issues of different severity levels to the error log. The error_log directive sets up logging to a particular file, stderr , or syslog and specifies the minimal severity level of messages to log. By default, the error log is located at logs/error.
The syntax for disabling the error log is ok, but the docs state that a default logfile is used before the config is read. (which seems reasonable because how would it otherwise tell you you have an error in your config)
Try creating this file by hand with the correct permissions for the user that runs nginx. Or try starting the server as root.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With