3.6. Apache Log Files

Apache keeps detailed logs of accesses to your web site, errors, and more. The Apache logs are located at /var/log/httpd/access_log and /var/log/httpd/error_log. These locations are configurable in httpd.conf.

It’s a good idea to have a log monitor program running, such as swatch or logwatch, to keep an eye on these files for security violations and problems (see www.logwatch.org). It’s also a good idea to rotate them regularly via logrotate, because they’ll get big otherwise.

Of course, the most important use of the logs is to look at them when there is a problem to figure out what went wrong.

An access_log entry might look like this:

 192.168.1.12 - - [21/May/2001:14:10:05 -0600] "GET / HTTP/1.0" 200 43 "http://www.onsight.com/" ...

Get Open Source Web Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.