Apache Logs (Awstats)

The Apache httpd.conf directive "LogFormat" defines a log formatting that can then be referenced using its name. The following 2 examples define the log formats named: "combinedv" and "combined".

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %V" combinedv
CustomLog pathtoyourlog/yourlog.log combinedv

Or the standard NCSA combined/XLF/ELF format (this format should already be defined in the distribution httpd.conf file).
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog /yourlogpath/yourlogfile combined

The CustomLog item is required, if you want to use a specified LogFormat and save the logs in a specific folder. Usually webmasters will want to save logs for each site in the appropriate "site" folder.


For log rotation "ala" IIS, you need to use the "piped logfile" feature. This will pipe/send all the logs to a external program that will then be responsible for the rotation of the logs.

You can simulate the IIS log naming using string substitutions:
%y 2-digit year
%m 2-digit month
%d 2-digit day of month
Ref: http://httpd.apache.org/docs/2.2/programs/rotatelogs.html#portability

To imitate IIS type log filenames, I use log files defined with: ex%y%m%d.log
Here is what my log definition looks like in my "VirtualHost":
CustomLog "|E:/Apache220/bin/rotatelogs.exe E:/DomZeus/sitebuddycom/W3SVC1066/ex%y%m%d.log 86400" combined

Important Update: The 2 tested log rotation programs rotatelogs.exe and cronolog.exe are dangerous, see:
http://www.sitebuddy.com/Apache_Rotatelogs.exe_Bug

Ref: http://httpd.apache.org/docs/2.2/programs/rotatelogs.html

For Awstats:
Examples for Apache combined logs (following two examples are equivalent):
LogFormat = 1
LogFormat = "%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot"

So if you are using the "combined" log format, you can set "LogFormat = 1" for yoursite.

Note:
LogFormat Directive scope: server config, virtual host (Module: mod_log_config)
CustomLog Directive scope: server config, virtual host (Module: mod_log_config)
TransferLog Directive scope: replaced with CustomLog
This directive is a limited version of CustomLog.

Ref: http://httpd.apache.org/docs/2.2/mod/mod_log_config.html
http://httpd.apache.org/docs/2.2/programs/rotatelogs.html
http://awstats.sourceforge.net/docs/awstats_config.html#LogFormat
http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#customlog