# MAIN SETUP SECTION (Required to make AWStats working)
#------------------------------------------------------------------------
-# "LogFile" contains the web server logfile name to analyze.
-# You can use a full path...
+# "LogFile" contains the web server logfile to analyze.
+# You can use a full path or relative path from awstats.pl directory.
# Example: "/var/log/apache/access.log"
-# or relative path from awstats.pl directory...
# Example: "../logs/mycombinedlog.log"
#
-# You can also use %YY %MM %DD %HH or %WM in file name, AWStats will
-# replace those tags with current year month day hour or
-# week of month.
-# Example: "C:/WINNT/system32/LogFiles/W3SVC1/ex%YY%MM%DD.log"
+# You can also use tags in this filename if you need a dynamic file name
+# depending on date or time (Replacement is made by AWStats at the beginning
+# of its execution). This is available tags :
+# %YYYY-n is replaced with 4 digits year we were n hours ago
+# %YY-n is replaced with 2 digits year we were n hours ago
+# %MM-n is replaced with month we were n hours ago
+# %DD-n is replaced with day we were n hours ago
+# %HH-n is replaced with hour we were n hours ago
+# %WM-n is replaced with the week number in month (1-5)
+# You can use n=0 if you need current year, month, day, hour...
+# Example: "/var/log/access_log.%YYYY-24%MM-24%DD-24.log"
+# Example: "C:/WINNT/system32/LogFiles/W3SVC1/ex%YY-0%MM-0%DD-0.log"
#
LogFile="/var/log/httpd/mylog.log"
KeepBackupOfHistoricFiles=0
# Set your primary language.
-# Possible value:
+# Possible value:
# Bosnian=ba, Chinese (Taiwan)=tw, Chinese (Traditional)=cn, Czech=cz,
# Danish=dk, Dutch=nl, English=en, French=fr, German=de, Greek=gr,
# Hungarian=hu, Indonesian=id, Italian=it, Japanese=jp, Korean=kr,
%MonthBytes = %MonthHits = %MonthHostsKnown = %MonthHostsUnknown = %MonthPages = %MonthUnique = %MonthVisits =
%monthlib = %monthnum = ();
-$VERSION="3.2 (build 65)";
+$VERSION="3.2 (build 66)";
$Lang="en";
# Default value
# Read main section
if ($param =~ /^LogFile/) {
$LogFile=$value;
- # Replace %YYYY %YY %MM %DD %HH with current value
+ if ($LogFile =~ /%([YMDH]+)-(\d*)/) {
+ my $timephase=$2;
+ debug(" Found a time phase of $timephase hour in log file name",1);
+ # Get older time
+ ($oldersec,$oldermin,$olderhour,$olderday,$oldermonth,$olderyear,$olderwday) = localtime($nowtime-($timephase*3600));
+ $olderweekofmonth=int($olderday/7);
+ $olderdaymod=$olderday%7;
+ $olderwday++;
+ if ($olderdaymod <= $olderwday) { if (($olderwday != 7) || ($olderdaymod != 0)) { $olderweekofmonth=$olderweekofmonth+1; } }
+ if ($olderdaymod > $olderwday) { $olderweekofmonth=$olderweekofmonth+2; }
+ if ($olderyear < 100) { $olderyear+=2000; } else { $olderyear+=1900; }
+ $oldersmallyear=$olderyear;$oldersmallyear =~ s/^..//;
+ if (++$oldermonth < 10) { $oldermonth = "0$oldermonth"; }
+ if ($olderday < 10) { $olderday = "0$olderday"; }
+ if ($olderhour < 10) { $olderhour = "0$olderhour"; }
+ if ($oldermin < 10) { $oldermin = "0$oldermin"; }
+ if ($oldersec < 10) { $oldersec = "0$oldersec"; }
+ $LogFile =~ s/%YYYY-$timephase/$olderyear/g;
+ $LogFile =~ s/%YY-$timephase/$oldersmallyear/g;
+ $LogFile =~ s/%MM-$timephase/$oldermonth/g;
+ $LogFile =~ s/%DD-$timephase/$olderday/g;
+ $LogFile =~ s/%HH-$timephase/$olderhour/g;
+ $LogFile =~ s/%WM-$timephase/$olderweekofmonth/g;
+ }
+ # Replace %YYYY %YY %MM %DD %HH with current value. Kept for backward compatibility.
$LogFile =~ s/%YYYY/$nowyear/g;
$LogFile =~ s/%YY/$nowsmallyear/g;
$LogFile =~ s/%MM/$nowmonth/g;
$LogFile =~ s/%DD/$nowday/g;
$LogFile =~ s/%HH/$nowhour/g;
$LogFile =~ s/%WM/$nowweekofmonth/g;
+ debug(" LogFile=$LogFile",1);
next;
}
if ($param =~ /^LogFormat/) { $LogFormat=$value; next; }