Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx understanding access log column

Tags:

logging

nginx

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). 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.

like image 737
Dewsworld Avatar asked Nov 06 '14 13:11

Dewsworld


People also ask

How do I read Nginx logs?

The NGINX logs all client requests just after the request is processed in the access logs. In access logs, You will see the files are accessed, how NGINX responded to a request, which browser a client is using, client IP addresses, and more in this section.

How do I change the log format in nginx?

The syntax for configuring a log format is: log_format format_name 'set_of_variables_to_define_format'; and the syntax for configuring access log is: access_log /path/to/log_file format_name; #simplest form OR access_log /path/to/log_file [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]];

Can I delete nginx access log?

You can remove access. log as root user, or using sudo.

How long are Nginx logs kept?

You can set up logrotate for nginx, in this way you can maintain logs for 30 days or more as per your requirements !


2 Answers

The column after "Response Code" (i.e. status) is "Bytes Sent".

The default log format in nginx is called "combined". 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

like image 135
stevendaniels Avatar answered Sep 20 '22 18:09

stevendaniels


In your given example,

177, 4223, 4356 indicates the number of bytes sent, excluding the HTTP headers.

Default logs provided by both Apache and NGINX are pretty much identical. While the variable naming conventions differ, the information available is relatively the same.

like image 43
Shree Avatar answered Sep 19 '22 18:09

Shree