Nginx log_format性能参数$request_time $upstream_response_time


log_format是指存储日志的时候所采用的格式,可以在/usr/local/nginx/conf/nginx.conf的http字段中设置

默认配置如下:

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

在分析性能过程,有时需要分析请求耗时,可以添加$request_time $upstream_response_time两个参数实现。

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for $request_time $upstream_response_time $upstream_addr $upstream_status"';

    access_log  logs/access.log  main;

具体参数解释如下: