Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx trying to log to /var/logs instead of /var/log?

Tags:

nginx

I noticed when I test my nginx config using nginx -t, it gives me a warning:

nginx: [alert] could not open error log file: open() "/var/logs/nginx/error.log" failed (2: No such file or directory)

Which makes sense, since the log path for nginx is actually set up to be /var/log/nginx/ not /var/logs/nginx.

I scanned the entire nginx config directory and there is nothing there referencing /var/logs. I'm at a loss as to where this log location could be written?

like image 371
Brian Avatar asked Mar 27 '13 23:03

Brian


1 Answers

Run this command in a terminal (note: capital V):

nginx -V

Do you find /var/logs there? Your nginx might be compiled with that default file location.

[EDIT]

I guess that some of your server blocks don't have the "error_log" directive. So nginx tries the default one for them. Note that by default the error_log is always on.

To fix this issue, you can add this line on the main block (the top level) such that all child blocks can inherit the setting:

error_log /var/log/nginx/error.log;
like image 103
Chuan Ma Avatar answered Sep 28 '22 02:09

Chuan Ma