简体   繁体   中英

Log client request without waiting for server response

I am using nginx's access log to log client request.

Configuration I have used is below:

http {
    log_format keep_log '$remote_addr - $remote_user [$time_local] '
                           '"$request" $status $body_bytes_sent '
                           '"$http_referer" "$http_user_agent" "$gzip_ratio"';

    server {
        gzip on;
        access_log /var/logs/nginx/access.log keep_log;
        ...
    }
}

Nginx does keep the access log perfectly but the problem is, the server I am using behind nginx taking too much time to response back to the client. So nginx waiting for the server to response back and then when server send the response, nginx add the log with status code.

Is there any way to keep log as soon as client make a request to nginx without waiting for the backend server response?

即使从理论上讲也是不可能的,因为那时日志中的部分字段是未知的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM