在nginx日志中记录请求参数和header信息
(2012-01-13 12:03:48)
标签:
nginxlogheaderit |
分类: webserver |
直接上代码
log_format access '$remote_addr - $remote_user [$time_local]
"$request" $status
$body_bytes_sent $request_body "$http_referer"
"$http_user_agent"
$http_x_forwarded_for';
access_log
/var/log/nginx/access.log access;
主要是这个 $request_body
记录header信息,要使用nginx的upstream
log_format timing '$remote_addr - $remote_user
[$time_local] $request ' 'upstream_response_time
$upstream_response_time ' 'msec $msec request_time $request_time';
log_format up_head '$remote_addr - $remote_user [$time_local]
$request ' 'upstream_http_content_type
$upstream_http_content_type';
access_log
/var/log/nginx/access.log up_head;
$upstream_http_content_type就是header相应头的Content-Type