Apache config and .htaccess - logging
From Helpful
See also Category:Apache. Some of the interesting articles:
|
| These are primarily notes This is probably not going to be complete in any real sense, and exists to contain bits of useful information. |
[edit]
Formats
| This article/section is a stub — probably a pile of half-sorted notes and assertions some of which may well be wrong, and not verified as a whole. Feel free to add or refine. |
The "Common Log Format" used by apache (and imitated by others) is:
LogFormat "%h %l %u %t \"%r\" %>s %b" common
...which looks like:
127.0.0.1 - - [17/Apr/2008:12:23:32 +0200] "POST /foo.txt HTTP/1.1" 200 117
The "Combined Log Format" adds two header values, referer and user-agent:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
...which looks like (line-broken for readability)
127.0.0.1 - - [17/Apr/2008:12:23:32 +0200] "GET /foo.txt HTTP/1.1" 200 117 "http://www.example.com/start.html" "Opera/9.20 (Windows NT 6.0; U; en)"
Normally user agent isn't logged, or logged into a separate file (for simple counting) e.g. like:
CustomLog logs/agent_log "%{User-agent}i"
When you use virtual hosts, you won't be able to tell requests to different vhosts apart using common or combined log format. You probably want either to
- Log different vhost to distinct files: Specify a CustomLog and ErrorLog in each vhost. Note that when you run a shared server serving hundreds or thousands of vhosts, this may help you run into the host system's (configured) limit of file descriptors per process.
- Use a single log file, and a format that adds the virtual host per request (%v). You can tell analysois programs to split this into per-vhost logfiles if you wish.
(verify):
The 'commonvhost' format seems to log the vhost name instead of the client host name/IP:
LogFormat "%v %l %u %t \"%r\" %>s %b" commonvhost
You may want your own format, for example:
#common with vhost prepended: LogFormat "%v %h %l %u %t \"%r\" %>s %b" customcommon
#combined with vhost prepended
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" customcombined
See also the format strings you can use.
[edit]
Selective / separated Separate access/statistics notes
[edit]

