默认的日志格式:
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';由于默认的日志格式不能满足日常查看需要求,对其进行调整
修改后的日志格式:
'$remote_addr - $remote_user [$time_local] $request_time $request_method "$request_uri" $http_host '
'$status $body_bytes_sent $upstream_response_time $upstream_addr $upstream_status "$http_referer" $request_body''"$http_user_agent" "$http_x_forwarded_for" ';json日志格式:
log_format json '{"remote_addr":"$remote_addr",' '"remote_user":"$remote_user",' '"access_time":"$time_local",' '"request_method":"$request_method",' '"request_uri":"$request_uri",' '"http_host":"$http_host",' '"status":"$status",' '"body_bytes_sent":"$body_bytes_sent",' '"request_time":"$request_time",' '"status":"$status",' '"up_response_time":"$upstream_response_time",' '"up_addr":"$upstream_addr",' '"up_status":"$upstream_status",' '"http_referrer":"$http_referer",' '"agent":"$http_user_agent",' '"http_x_forwarded_for":"$http_x_forwarded_for"}';