There are two main types of nginx logs: access logs and error logs. The access log mainly records every request of the client to access nginx, and the format can be customized; the error log mainly records the log when the client accesses nginx and an error occurs, and the format does not support customization. Both logs can be optionally turned off.
Through the access log, you can get relevant information such as the user’s geographical origin, jump source, usage terminal, number of visits to a certain URL; through the error log, you can You can get the performance bottleneck of a certain service or server in the system. Therefore, by making good use of logs, you can get a lot of valuable information.
Access Log
[Access.log]
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';
Description:
#Variable name |
Variable description |
Example |
||||||||||||||||||||||||||||||||||||||||||||||||||||
$remote_addr |
Client address | ##113.140. 15.90 |
||||||||||||||||||||||||||||||||||||||||||||||||||||
##$remote_user Client user name |
-
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||
Access time and time zone |
18/Jul/ 2012:17:00:01 0800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
Requested URI | and
HTTPProtocol "GET /pa/img/home/logo-alipay-t.png HTTP/1.1" |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
The request address is the address you enter in the browser ( IP | or domain name )
img.alipay.com |
##10.253.70.103 ##$status |
||||||||||||||||||||||||||||||||||||||||||||||||||||
HTTPRequest Status |
200 |
$upstream_status |
||||||||||||||||||||||||||||||||||||||||||||||||||||
##upstreamstatus |
200 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||
$body_bytes_sent |
The size of the file content sent to the client |
547 |
||||||||||||||||||||||||||||||||||||||||||||||||||||
#$http_referer |
Jump source | "https://cashier.alipay.com.../" |
||||||||||||||||||||||||||||||||||||||||||||||||||||
##$http_user_agent | User Terminal Agent"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1 ; Trident/4.0; SV1; GTB7.0; .NET4.0C; |
|||||||||||||||||||||||||||||||||||||||||||||||||||||
##$ssl_protocol
| ##SSLProtocol Version
| TLSv1 |||||||||||||||||||||||||||||||||||||||||||||||||||||
Algorithm in exchange data |
RC4-SHA |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
The address of the background upstream | , that is, the address of the host that actually provides the service 10.228.35.247:80 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||
The total time of the entire request |
0.205 |
##$upstream_response_time |
||||||||||||||||||||||||||||||||||||||||||||||||||||
During the request ,upstreamResponse time |
##0.002 |
Note: The value of $http_host is related to the value you enter in the browser. Error log "upstream prematurely (premature) closed connection" uri is caused by the user disconnecting when upstream has not returned a response to the user. It has no impact on the system and can be ignored
Down some of the connections; ( ( Stop
upstream hangs or is unavailable, you will receive this Error
is used to set the client requests that are allowed to be accepted. The maximum value of the content, the default value is client exceeds the set value User sends "gracefully shutting down", USEkill -WINCH instruction "no servers are inside upstream" upstream Deploymentserver ##"no live upstreams while connecting to upstream" upstream下下server全都挂了 "SSL_do_handshake() failed" SSL handshake failed "SSL_write( ) failed (SSL:) while sending to client"
## |
The above is the detailed content of How to read nginx logs. For more information, please follow other related articles on the PHP Chinese website!