在现网环境中nginx的访问日志对于故障定位(接口超时、网络异常)以及统计分析都十分有用,推荐使用以下log_format格式:
log_format main '$remote_addr-$remote_user [$time_local][$status][$host] "$request" "$request_body"'
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$gzip_ratio" $request_time $bytes_sent $request_length';