加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

在nginx日志中记录请求参数和header信息

(2012-01-13 12:03:48)
标签:

nginx

log

header

it

分类: 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

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有