Main Page / Browse Categories / Howto's & Guides / Understanding your Logs
Understanding your Logs
Log Files assist to effectively manage a web server, making it is possible to get feedback about the activity and performance of the server as well as any problems that may be occurring. The Apache HTTP Server provides very comprehensive and flexible logging capabilities.
 
 
Access Log

The server access log records all requests processed by the server. The location and content of the access log are controlled by the CustomLog directive. The LogFormat directive can be used to simplify the selection of the contents of the logs.

The format of the access log is highly configurable. The format is specified using a format string that looks much like a C-style printf(1) format string. The format string used here is called the Combined Log Format. It is setup as follows:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined CustomLog logs/access_log combined

Here is a sample log entry using the above format:

127.0.0.1 - - [02/Apr/2002:22:38:48 -0800] "GET / HTTP/1.1" 200 3983 "http://www.yoursite.com" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90)"

127.0.0.1 (%h)
The IP address for the viewer who access your site (i.e. 127.0.0.1).

- (%l)
The "hyphen" in the output indicated that the requested piece of information is not available.

- (%u)
This is the userid of the person requesting the document as determined by HTTP authentication. If the document is password protected, this entry will appear as "username", otherwise it will be "-".

[03/Apr/2002:06:15:32 -0800] (%t)
Shows the time that the server finished processing the request. The format is [day/month/year:hour:minute:second zone]

"GET / HTTP/1.1" (\"%r\")
The request line from the client is given in double quotes. The request line contains a great deal of useful information. First, the method used by the client is GET. Second, the client requested the resource / and third, the client used the protocol HTTP 1.1.

200 (%>s)
This is the status code that the server sends back to the client. This information is very valuable, because it reveals whether the request resulted in a successful response (codes beginning in 2), a redirection (codes beginning in 3), an error caused by the client (codes beginning in 4), or an error in the server (code beginning in 5).

3983 (%b)
This indicates the size of the object returned to the client, not including the response headers. If no content was returned to the client, this value will be "-".

"http://www.yoursite.com" (\"%Referer)i\")
The "Referer" (sic) HTTP request header. This gives the site that the client reports having been referred from. If the address was entered into the address bar, this value will be "-".

"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90)" (\"%(User-agent)i\")
The User-Agent HTTP request header. This is the identifying information that the client browser reports about itself.

 

Error Log

The server error log, whose name and location is set by the ErrorLog directive, is the most important log file. This is the place where Apache httpd will send diagnostic information and record any errors that it encounters in processing requests. It is the first place to look when a problem occurs with starting the server or with the operation of the server, since it will often contain details of what went wrong and how to fix it.

The error log is written to a file (error_log under the logs folder).

The format of the error log is relatively free-form and descriptive. But there is certain information that is contained in most error log entries. For example, here is a typical message:

[Wed Apr 3 22:50:36 2003] [error] [client 127.0.0.1] File does not exist: /home/httpd/vhosts/yoursite.com/httpdocs/index.php

Date & Time [Wed Apr 3 22:50:36 2003]
Shows the date and time for which the error occurred

Error ([error])
Shows that it was in fact an error

IP Address ([client 127.0.0.1])
The IP address for the viewer who encountered the error

Error Statement (File does not exist)
Shows the reason for the error (i.e. Premature end of script headers).
The error statement can show you exactly what caused the error. Several common error
statements include:

Premature end of script headers (500 Error) - CGI Scripts
File does not exist (404 Error)
Forbidden (403 Error)

File System Path (/home/httpd/vhosts/yoursite.com/httpdocs/index.php)
Shows the requested document for which the error occurred



User Comments
Understanding your Logs
Add Comment
There are no user comments for this topic.
Add Comment
Additional Info
General Information
Article No. 195
Created: 04:37 AM 12.26.03
Author: HPU Support

Attachments
No attachments.

Did this help you?
Yes No

Statistics
Yes727 (48%) Voted Yes794 (52%) Voted NoNo

Other Options
Print Article
Email Article

Related Articles
Understanding the Basics of Electronic Mail
How to Set up Streaming Audio and Video?