Learn more about the world's best-loved Web server, with examplesof Apache's authentication and logging capabilities, and also pay a briefvisit to its unique URL re-writing module.
You may not know this, but Apache comes with some pretty impressive loggingcapabilities, which allow you to record demographic information aboutvisitors to your Web site. And these logging capabilities can be customizedto deliver exactly the information you need for later analysis.
Apache comes with two types of logs: there's the "access log", which trackseach and every request made to the Web server, and the "error log", whichtracks internal server errors, missing file and the like. There are anumber of configuration directives in the "httpd.conf" file which allow youto control Apache's default logging behaviour.
The ErrorLog directive specifies the location of the error log.
ErrorLog logs/error.log
The CustomLog directive specifies the location of the server's access log,together with a format for the log file (as defined in the LogFormatdirective). The default setting is the Common Logfile Format, whichplaces each request on a separate line; this format records the IP address,the date and time, the bytes sent, and the first line of the client request.
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog logs/access.log common
The variables that you see in the LogFormat directive are server variablesthat return various identifiers for each client request - you can use theseto create your own log format. More information about each variabledoes can be obtained from the Apache manual athttp://httpd.apache.org/docs/mod/mod_log_config.html#customlog , or fromthe list below.
%h - requesting host
%b - bytes sent
%{VARNAME}e - value of environment variable VARNAME