Nginx log logs are divided into Access log and error log
where access log records which users, which pages, and the user's browser, IP, and other access information
Error log is the record server error logs
The error log is in the following form:
10.1.1.1--[22/aug/2015:16:48:14 +0800] "post/ajax/mbprequest.do http/1.1" "367"-"" dalvik/1.6.0 (Linux; U Android 4.1.1; armm7k build/jro03h) "119.189.56.175" 127.0.0.1:8090 0.022 0.022
10.1.1.1--[22/aug/2015:16:48:19 +0800] "post/ajax/mbprequest.do http/1.1" "616"-"" dalvik/1.6.0 (Linux; U Android 4.0.4; gt-i9103 build/imm76d) "36.250.89.22" 127.0.0.1:8090 0.036 0.036
From the above we can see a few pieces of information:
1. Client (user) IP address. Example: 10.1.1.1 in the above example (intranet load balancer address)
2. Access time. Example: [22/aug/2015:16:48:19 +0800] in the example above
3. Access the port. such as: 127.0.0.1:8080 in the above example
4. Response time. such as: 0.022 in the previous example
5. Request time. such as: 0.022 in the previous example
6. User Location Code (country code).
7. Host of the requested URL address (destination URL address). Such as: The above example of the/....
8. Request method (get or post, etc.). Example: The GET in the previous example
9. Request the URL address (remove the host section). such as:/html/test.html in the above example
10. Request Status (status code, 200 indicates success, 404 means the page does not exist, 301 means permanent redirect, etc.), the status code can be found on the Internet related articles, no longer repeat. such as: "200" in the above example
11. Request page size, default to B (Byte). such as: 2426 in the previous example
12. Source page, that is, from which page to go to this page, the professional name is called "Referer". such as: "Http://a.com" in the above example
13. User Browser language. such as: "es-es,es;q=0.8" in the above example
14. User browser Other information, browser version, browser type, etc. Example: "mozilla/5.0 (Windows NT 6.1) applewebkit/537.11 (khtml, like Gecko) chrome/23.0.1271.97 safari/537.11" in the example above
In fact, the format of the Nginx access log is not immutable and can be customized.
Found in nginx nginx.conf configuration file: Log_format Here is the format of the log
Look at the log format settings that match the above logs:
#access日志格式配置, the specific parameters are no longer detailed, the above has been said, their corresponding can be
log_format main ' $remote _addr-$ Remote_user [$time _local] "$request" '
' $status $body _bytes_sent "$http _referer" '
' $http _user_agent "" $http _x_forwarded_for "'
' $upstream _addr $upstream _ Response_time $request _time ';
access_log logs/access.log main;
#配置access log log storage location and file, Note: Access.log file can be divided by date, easy to view and processing
Access_log/usr/local/nginx/log/access.log main;
Explanation of the relevant explanation
1. $remote _addr and $http_x_forwarded_for to record the IP address of the client;
2. $remote _user: Used to record the client user name;
3. $time _local: Used to record access time and time zone;
4. $request: The URL used to record the request and the HTTP protocol;
5. $status: Used to record the status of the request; success is 200.
6. $body _bytes_s ent: Record the size of the principal content sent to the client file;
7. $http _referer: Used to record links from that page to access;
8. $http _user_agent: Record information about the client browser;
This article is from the "Good Big Knife" blog, please make sure to keep this source http://53cto.blog.51cto.com/9899631/1694739
Analysis of Nginx log format