Getting More Out Of Apache (Part 2) - Timmmmmmbbbbberrrr! (Page 5 of 8 )
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 at
http://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
%t - timestamp
%h - remote host
%T - time taken to serve request (seconds)
%U - URL requested
%s - return code for request
%{User-agent}I - remote user agent identifier
Next: When Things Go Wrong >>
More Administration Articles
More By icarus, (c) Melonfire