'No error logs in /var/log/nginx/error.log [nginx]

The nginx on my Google Linux server is not printing error logs in the file /var/log/nginx/error.log. The content of my /etc/nginx/sites-available/app file is:

server {
    listen 80;
    server_name xx.xx.xx.xx;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/home/user_name/app/app.sock;
    }
}

I am using python-flask. Till now, I have been using logging module of python to log data but obviously I had to figure out the problem. When viewing /var/log/nginx/ folder, I can see various error.log and access.log files. I deleted the error.log to check whether it is created again or not. It was created again but still doesn't have any logs of the 500 Server errors. By the way if it helps, I followed this guide to set it up.



Solution 1:[1]

You need to define error_log directive by your own, for example in server {} context:

server {
    listen 80;
    server_name xx.xx.xx.xx;

    error_log /var/log/nginx/error.log;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/home/user_name/app/app.sock;
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user973254