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';


log_format  main  '$remote_addr $remote_user [$time_local] "$request" $http_host '

                  '$status $upstream_status $body_bytes_sent "$http_referer" '

                  '"$http_user_agent" $ssl_protocol $ssl_cipher $upstream_addr '

                  '$request_time $upstream_response_time'; 

变量名称
变量描述
举例说明
$remote_addr
客户端地址
113.140.15.90
$remote_user
客户端用户名称
-
$time_local
访问时间和时区
18/Jul/2012:17:00:01 +0800
$request
请求的URI和HTTP协议
"GET /pa/img/home/logo-alipay-t.png HTTP/1.1"
$http_host
请求地址,即浏览器中你输入的地址(IP或域名)
img.alipay.com
10.253.70.103
$status
HTTP请求状态
200
$upstream_status
upstream状态
200
$body_bytes_sent
发送给客户端文件内容大小
547
$http_referer
跳转来源
 "https://cashier.alipay.com.../"
$http_user_agent
用户终端代理
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; GTB7.0; .NET4.0C;
$ssl_protocol
SSL协议版本
TLSv1
$ssl_cipher
交换数据中的算法
RC4-SHA
$upstream_addr
后台upstream的地址,即真正提供服务的主机地址
10.228.35.247:80
$request_time
整个请求的总时间
0.205
$upstream_response_time
请求过程中,upstream响应时间
0.002

你可能感兴趣的:(解析)