Linux Server access_log log analysis and configuration details (i)

Source: Internet
Author: User

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:

12 201.158.69.116 - - [03/Jan/2013:21:17:20 -0600] fwf[-] tip[-] 127.0.0.1:9000 0.007 0.007 MX pythontab.com GET /html/test.html HTTP/1.1 "200"2426 "http://a.com""es-ES,es;q=0.8""Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"187.171.69.177 - - [03/Jan/2013:21:17:20 -0600] fwf[-] tip[-] 127.0.0.1:9000 0.006 0.006 MX pythontab.com GET /html/test2.html HTTP/1.1 "200"2426 "http://a.com""es-ES,es;q=0.8""Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"

From the above we can see a few pieces of information:

1. Client (user) IP address. such as: 201.158.69.116 in the above example

2. Access time. Example: [03/jan/2013:21:17:20-0600] in the example above

3. Access the port. such as: 127.0.0.1:9000 in the above example

4. Response time. such as: 0.007 in the previous example

5. Request time. such as: 0.007 in the previous example

6. User Location Code (country code). Example: MX (Mexico) in the example above

7. Host of the requested URL address (destination URL address). such as: Pythontab.com in the above example

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:

12345678910 #access日志格式配置,具体参数不再细说,上面都已经说过了,自己对应一下即可log_format main ‘$remote_addr - $remote_user [$time_local] ‘                     ‘fwf[$http_x_forwarded_for] tip[$http_true_client_ip] ‘                     ‘$upstream_addr $upstream_response_time $request_time ‘                     ‘$geoip_country_code ‘                     ‘$http_host $request ‘                     ‘"$status" $body_bytes_sent "$http_referer" ‘                     ‘"$http_accept_language" "$http_user_agent" ‘;#配置access log日志的存储位置及文件,注意:access.log文件是可以按日期进行分割的,方便查看及处理access_log  /home/serversoft/nginx/log/access.log  main;

 

Linux Server access_log log analysis and configuration details (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.