Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make nginx try_files log file when it is not found?

Tags:

nginx

server {
    server_name foo.com;

    listen 80;

    root '/var/www';

    location /divergent {
        try_files 'bar' =400;
    }
}

In this example, I would like to get a message such as:

2015/03/27 17:53:49 [error] 25248#0: *1 open() '/var/www/bar' failed (2: No such file or directory), client: 37.187.147.109, server: foo.com, request: "GET /bar HTTP/1.1", host: "foo.com"

I would like to get the above message; I do get it sometimes, sometimes I do not. I do not understand what makes the message to propagate.

HTTP block is configured to log all messages:

http {
    error_log /var/log/nginx/error.log debug;

    # ...
}
like image 636
Gajus Avatar asked Mar 27 '15 18:03

Gajus


1 Answers

This was achieved by rebuilding Nginx with debug information, using the --with-debug flag. For build instruction, see debugging log documentation.

This allows printing additional information using error_log /path/to/log debug; instruction. See error_log for details.

like image 75
Adrien Leravat Avatar answered Oct 21 '22 21:10

Adrien Leravat