简体   繁体   English

"Nginx理解访问日志专栏"

[英]Nginx understanding access log column

I understand all the column of this app's access log- IP, date, request, response code and... except the next column is what I don't understand (in the example below, 177, 4223, 4356).我了解此应用程序访问日志的所有列 - IP、日期、请求、响应代码和...除了下一列是我不了解的内容(在下面的示例中,177、4223、4356)。 What is this stands for?这是什么意思?

66.249.65.159 - - [06/Nov/2014:19:10:38 +0600] "GET /news/53f8d72920ba2744fe873ebc.html HTTP/1.1" 404 177 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
66.249.65.3 - - [06/Nov/2014:19:11:24 +0600] "GET /?q=%E0%A6%AB%E0%A6%BE%E0%A7%9F%E0%A6%BE%E0%A6%B0 HTTP/1.1" 200 4223 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
66.249.65.62 - - [06/Nov/2014:19:12:14 +0600] "GET /?q=%E0%A6%A6%E0%A7%8B%E0%A7%9F%E0%A6%BE HTTP/1.1" 200 4356 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

Edit: I've googled, but couldn't find any answer.编辑:我用谷歌搜索,但找不到任何答案。

The column after "Response Code" (ie status) is "Bytes Sent". “响应代码”(即状态)之后的列是“发送的字节数”。

The default log format in nginx is called "combined". nginx中的默认日志格式称为“组合”。 It is the equivalent to the following configuration. 它等同于以下配置。

# nginx.conf
http {
  ...
  log_format combined '$remote_addr - $remote_user [$time_local] '
                      '"$request" $status $body_bytes_sent '
                      '"$http_referer" "$http_user_agent"';
  ...
}

Source: Module ngx_http_log_module 来源:模块ngx_http_log_module

In your given example, 在你给出的例子中,

177, 4223, 4356 indicates the number of bytes sent, excluding the HTTP headers. 177,4223,4356表示发送的字节数,不包括HTTP头。

Default logs provided by both Apache and NGINX are pretty much identical. Apache和NGINX提供的默认日志完全相同。 While the variable naming conventions differ, the information available is relatively the same. 虽然变量命名约定不同,但可用信息相对相同。

NGINX Logging Variables Documentation<\/a><\/strong> NGINX 记录变量文档<\/a><\/strong>

In this link you can find all possible variables that can be used in nginx logging with their descriptions ...在此链接中,您可以找到可在 nginx 日志记录中使用的所有可能变量及其描述...

Additionally, you can config nginx to create custom logs with your favourite template:此外,您可以配置 nginx 以使用您喜欢的模板创建自定义日志:

  1. edit \/etc\/nginx\/nginx.conf编辑 \/etc\/nginx\/nginx.conf

    <\/li>

  2. find 'access_log' lines查找“access_log”行

    <\/li>

  3. before this line, define your logging template(like below for example):在此行之前,定义您的日志记录模板(例如下面):

    log_format firelog '"$time_local" client=$remote_addr ' 'method=$request_method request="$request" ' 'request_length=$request_length ' 'status=$status bytes_sent=$bytes_sent ' 'body_bytes_sent=$body_bytes_sent ' 'referer=$http_referer ' 'user_agent="$http_user_agent" ' 'upstream_addr=$upstream_addr ' 'upstream_status=$upstream_status ' 'request_time=$request_time ' 'upstream_response_time=$upstream_response_time ' 'upstream_connect_time=$upstream_connect_time ' 'upstream_header_time=$upstream_header_time ' 'body=$request_body'; log_format firelog '"$time_local" client=$remote_addr ' 'method=$request_method request="$request" ' 'request_length=$request_length ' 'status=$status bytes_sent=$bytes_sent ' 'body_bytes_sent=$body_bytes_sent ' 'referer=$ http_referer ' 'user_agent="$http_user_agent" ' 'upstream_addr=$upstream_addr ' 'upstream_status=$upstream_status ' 'request_time=$request_time ' 'upstream_response_time=$upstream_response_time ' 'upstream_connect_time=$upstream_connect_time ' 'upstream_header_time=$upstream_header_time'请求体';

    <\/li>

  4. then update access line like below:然后更新访问线如下:

    access_log \/var\/log\/nginx\/firelog.log firelog; access_log \/var\/log\/nginx\/firelog.log firelog;

    <\/li><\/ol>"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM