How to log nginx requests made to a specific location in a different file?

Solution 1:

UPD

Hmmm... access_log directive have a "feature".

Requests are logged in a context of a location where processing ends. This may be different from the original location, if an internal redirect happens during request processing.

In case of try_files the internal redirect. Try change try_files to include & remove named location.

END OF UPD


In order not to repeat many times "proxy_ stuff", you can use include directive, for example. But try_files and named location are much better :)

server {
    ...
    access_log  /var/log/nginx/jira.access.log full;
    error_log  /var/log/nginx/jira.error.log;
    client_max_body_size 150m;

    location /special/ {
        try_files $uri @backend;
        access_log /var/log/nginx/special.access.log full;
    }

    location / {
        try_files $uri @backend;
    }

    location @backend {
            # many lines of config params for proxy_...
            proxy_pass   http://dowa-02.example.com:8080;
            ...
    }
}