@
julyclyde 注意要配置 escape=json,贴一个我自用的配置:
log_format main escape=json '{"timestamp":"$time_iso8601",'
'"server_addr":"$server_addr",'
'"server_port":"$server_port",'
'"host":"$host",'
'"hostname":"$hostname",'
'"client_addr":"$remote_addr",'
'"client_port":"$remote_port",'
'"server_name":"$server_name",'
'"request_uri":"$request_uri",'
'"uri":"$uri",'
'"https":"$https",'
'"x_forwarded_for":"$http_x_forwarded_for",'
'"scheme":"$scheme",'
'"request_method":"$request_method",'
'"args":"$args",'
'"referer":"$http_referer",'
'"http_user_agent":"$http_user_agent",'
'"request_length":$request_length,'
'"content_length":"$content_length",'
'"content_type":"$content_type",'
'"body_bytes_sent":$body_bytes_sent,'
'"bytes_sent":$bytes_sent,'
'"request_time":$request_time,'
'"status":$status,'
'"upstream_status": "$upstream_status",'
'"upstream_addr":"$upstream_addr",'
'"upstream_time":"$upstream_response_time",'
'"upstream_cache_status":"$upstream_cache_status"'
'}';