Rotating Access Logs with $date_local
Igal @ getRailo.org
igal at getrailo.org
Tue Oct 28 18:07:02 UTC 2014
On 10/28/2014 10:18 AM, Igal @ getRailo.org wrote:
> You mentioned multiple maps but why can't it be done with a single one?
>
> I managed to extract the year via
>
> map $time_local $date {
> ~(?P<year>\d\d\d\d) $year;
> }
>
> so this is much progress, but shouldn't I be able to do something like
>
> ~(?P<day>\d\d\d)/(?P<month>\w\w\w)/(?P<year>\d\d\d\d)"
> $year$month$day;
>
> ?
>
> unfortunately that throws an error: unknown "year$month" variable
I ended up using 4 maps for now. If you have a better idea (without
resorting to external utilities) I'd love to hear it:
## $time_local is in the format: 28/Oct/2014:11:00:04 -0700
map $time_local $date_year {
~^\d\d/\w\w\w/(?P<substr>\d\d\d\d) $substr;
}
map $time_local $date_month {
~^\d\d/(?P<substr>\w\w\w) $substr;
}
map $time_local $date_day {
~^(?P<substr>\d\d) $substr;
}
map $date_month $date_month_numeric {
Jan 1;
Feb 2;
Mar 3;
Apr 4;
May 5;
Jun 6;
Jul 7;
Aug 8;
Sep 9;
Oct 10;
Nov 11;
Dec 12;
default $date_month;
}
access_log
logs/$host-access-$date_year$date_month_numeric$date_day.log
standard_log_format;
--
Igal Sapir
Railo Core Developer
http://getRailo.org/
More information about the nginx
mailing list