ngnix日志格式分析

nginx 日志分析

#    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                     '$status $body_bytes_sent "$http_referer" '
#                      '"$http_user_agent" "$http_x_forwarded_for"';

意思如下

$remote_addr$http_x_forwarded_for 用以记录客户端的ip地址;
 $remote_user   :用来记录客户端用户名称;
 $time_local  : 用来记录访问时间与时区;  
 $request  :  用来记录请求的url与http协议;
 $status     :  用来记录请求状态;成功是200$body_bytes_s ent  :记录发送给客户端文件主体内容大小;
 $http_referer  :用来记录从那个页面链接访问过来的;
 $http_user_agent  :记录客户浏览器的相关信息;

如果加反应时间:

如下

log_format  access1  '$remote_addr - $remote_user [$time_local] "$request" '
              '$status $body_bytes_sent "$http_referer" '
              '"$http_user_agent" $http_x_forwarded_for  "$request_time"';

日志中便多出了响应时间;

192.168.7.212 - - [12/Oct/2011:10:58:11 +0800] "GET /mybooks/create_book_dialog/org:58/ HTTP/1.1" 200 6248 "http://www.domain.com/myrote/mybooks/org:58/type:0/filter:0/single:1/page:1" "Mozilla/5.0 (Windows NT 6.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" 202.142.28.130  "0.063"

应用

 log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                     '$status $body_bytes_sent "$http_referer"  $http_x_forwarded_for  "$upstream_addr"  "$request_time"';
$upstream_addr  访问的是哪台机器
$request_time  反映时间
 log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      'http_status $status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"'
                      'upstream_addr $upstream_addr request_time $request_time';

还没有评论,快来抢沙发!

发表评论

  • 😉
  • 😐
  • 😡
  • 😈
  • 🙂
  • 😯
  • 🙁
  • 🙄
  • 😛
  • 😳
  • 😮
  • emoji-mrgree
  • 😆
  • 💡
  • 😀
  • 👿
  • 😥
  • 😎
  • ➡
  • 😕
  • ❓
  • ❗
  • 66 queries in 0.384 seconds