How to analyze apache logs [access_log (access log) and error_log (error log)]

Source: Internet
Author: User
By default, Apache runs two log files: access_log (access log) and error_log (error log. Take a look at a typical acce

By default, Apache runs two log files: access_log (access log) and error_log (error log.
View the log record of a typical access_log:
61.155.149.20--[17/Dec/2013: 05: 42: 47 + 0800] "GET/category/db/HTTP/1.1" 200 23225
1) 61.155.149.20This is the client ip address requested to the apache server. by default, the first item is the ip address of the remote host. However, if we need apache to find the host name, you can set HostnameLookups to on, which is not recommended and greatly reduces the website speed.

2 )-This item is blank and is replaced by "-". it is used to record the viewer's identity. for most browsers, this item is empty.

3 )-It is also empty. it records the name provided by the viewer for identity verification. most of the names are empty.

4) [17/Dec/2013: 05: 42: 47 + 0800]The fourth is to record the request time in the format of [day/month/year: hour: minute: second zone]. The Last + 0800 indicates that the time zone of the server is UTC + 8.

5) "GET/category/db/HTTP/1.1"This is the most useful one. First, it tells our server to receive a GET request, second, the resource path of the client request, and third, HTTP/1.1 when the client uses the protocol, the entire format is "% m % U % q % H", that is, "request method/access path/protocol"

(6) 200This is a status code sent back to the client by the server. it tells us whether the client's request is successful, or is redirected, or what kind of error is encountered. The value is 200, indicates that the server has responded to the client's request successfully. generally, a value starting with 2 indicates that the request is successful, and a value starting with 3 indicates redirection, there are some errors in the client marked with "4" and some errors on the server marked with "5.

(7) 23225This indicates the number of bytes sent by the server to the client. During log analysis and statistics, the total number of bytes sent by the server at a certain time point can be known.

Let's take a look at error_log:
[Tue Dec 17 02:22:46 2013] [error] [client 61.182.137.33] File does not exist:/var/www/html/usr/themes/dddefault/all.txt
1) [Tue Dec 17 02:22:46 2013]Record the time when an error occurred. Note that it is different from the time format of the above access_log record.
2) [error]This is the error level. the error category is controlled according to the LogLevel command. the above 404 belongs to the error level.
3) [client 61.182.137.33]Record the client IP address
4) File does not exist:/var/www/html/usr/themes/dddefault/all.txtError description.
Recommended: (Apache logs are generated by nature)

Related Article

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.