Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off or specify the nginx error log location?

Tags:

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?

like image 752
Dean Chen Avatar asked Nov 14 '12 01:11

Dean Chen


People also ask

How do I disable NGINX error log?

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.

Where is the NGINX error log?

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.

How do I enable NGINX logs?

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.

What is NGINX error log?

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.


1 Answers

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.

like image 62
RickyA Avatar answered Nov 16 '22 23:11

RickyA