Reprinted from: http://www.cnblogs.com/LoveJulin/p/5082363.html
There are two main commands related to the nginx server log, one is log_format, which is used to set the log format, and the other is access_log, which is used to specify the storage path, format and cache size of the log file. Generally, the log configuration (/ usr/local/nginx/conf/nginx.conf).
nginx's log_format has many optional parameters to indicate the active status of the server, the default is:
log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '" $http_user_agent" "$http_x_forwarded_for"';
If you want to record more detailed information, you need to set the log_format yourself. The specific parameter formats and descriptions that can be set are as follows:
parameter | illustrate | Example |
$remote_addr | client address | 211.28.65.253 |
$remote_user | Client Username | -- |
$time_local | Access time and time zone | 18/Jul/2012:17:00:01 +0800 |
$request | Requested URI and HTTP protocol | "GET /article-10000.html HTTP/1.1" |
$http_host | The request address, which is the address (IP or domain name) you enter in the browser | www.it300.com 192.168.100.100 |
$status | HTTP request status | 200 |
$upstream_status | upstream status | 200 |
$body_bytes_sent | The size of the file content sent to the client | 1547 |
$http_referer | URL jump source | https://www.baidu.com/ |
$http_user_agent | User terminal browser and other information | "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; GTB7.0; .NET4.0C; |
$ssl_protocol | SSL protocol version | TLSv1 |
$ssl_cipher | Algorithms in exchanging data | RC4-SHA |
$upstream_addr | The address of the background upstream, that is, the address of the host that actually provides the service | 10.10.10.100:80 |
$request_time | total time for the entire request | 0.205 |
$upstream_response_time | During the request process, the upstream response time | 0.002 |