log_format main ‘$remote_addr $http_x_connecting_ip – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” $request_time “$upstream_http_content_type”‘;
这段代码要放在哪个位置
另外还需要做哪些配置
http {
include mime.types;
default_type application/octet-stream;
log_format main '{"remoteaddr":"$remote_addr","hostname":"$host","clientip":"$http_x_forwarded_for","timestamp":"$time_local","theme":"$scheme","http_verb":"$request_method",'
'"http_request_url":"$document_uri","http_request_args":"$args","http_version":"$http_version","request_time":$request_time,'
'"upstream_response_time":"$upstream_response_time","upstream_response_length":"$upstream_response_length",'
'"upstream_host":"$upstream_addr","http_status":"$status","bytes_read":"$body_bytes_sent","refferrer":"$http_referer","agent":"$http_user_agent"}';
}
放在这里, http中
这个逻辑放到http段中
1.6版本以前的,直接放到server中,1.6版本开始,可以直接在http中配置,在server中引用即可