格式下如下:
#原有的格式注销
# log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
log_format json '{"remote_ip":"$remote_addr",'
'"time_local":"$time_local",'
'"body_sent":$body_bytes_sent,'
'"responsetime":$request_time,'
'"upstreamtime":"$upstream_response_time",'
'"upstreamhost":"$upstream_addr",'
'"http_host":"$host",'
'"method":"$request_method",'
'"url":"$request_uri",'
'"request":"$request",'
'"xff":"$http_x_forwarded_for",'
'"referer":"$http_referer",'
'"agent":"$http_user_agent",'
'"response_code":"$status"}';
# access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/access.log json;