Apache log
files are configured in the /etc/httpd/logs directory, they’re actually stored
in the /var/log/httpd directory. Standard logging information from Apache is
stored in two baseline log files. Custom log files may also be configured. Such
log files may have different names, depending on how virtual hosts are
configured, how secure web sites are configured, and how logs are rotated.
Based on the standard
Apache configuration files, access attempts are logged in the access_log file
and errors are recorded in the error_log file. Standard secure log files include
ssl_access_log, ssl_error_log, and ssl_request_log.
In general, it’s
helpful to set up different sets of log files for different web sites. To that
end, you should set up different log files for the secure versions of a web
site. The traffic on a web site is important when choosing a log rotation
frequency.
There are standard
Apache log file formats. Four different formats: combined, common, the referrer
(the web page with the link used to get to your site), and the agent (the user’s
web browser). The first two LogFormat lines
include a number of percent signs followed by lowercase letters. These
directives determine what goes into the log.
# LogLevel: Control the number of
messages logged to the error log.
# Possible values include: debug,
info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn
#
# The following directives define
some format nicknames for use with
# a CustomLog directive (see below)
.
#
LogFormat “%h %l $u %t \ “%r\” %>S
%b \ “%{Referer}i\” \” ” combined
LogFormat “%h %l $u %t \ “%r\”
%>S %b” common
LogFormat “ %{Referer}i” agent
LogFormat “ %{User-agent}i” agent
# “combinedio” includes actual counts
of actual bytes received (%I) and send (%O) ; this
# requires the mod_logio module to
be loaded.
# LogFormat “%h %l %u %u %t \ “%r” %?s %b \ “ %{Referer}i\” \ “%{User-Agent}i\”
%I %O” combinedio
#
You can then use the CustomLog
directive to select a location for the log file, such as
logs/special_access_log, and the desired log file format, such as common. For more
information on log files and formats, refer to http://localhost/manual/logs.html.
Some web log analyzers have specific
requirements for log file formats. For example, the popular open-source tool
awstats (advanced Web Stats) requires the combined log format. It will fail to
run if you leave the default common format. Awstats is a great tool for
graphically displaying site activity. You can download it from a site such as www.sourceforge.net.