在http中
如果要在http
块中设置access_log
,可以使用map
设置变量
map $time_iso8601 $logdate {
'~^(?<ymd>\d{4}-\d{2}-\d{2})' $ymd;
default 'date-not-found';
}
日志路径
access_log logs/$logdate-access.log;
在server
或location中
定义变量
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
}
日志路径
access_log logs/$year-$month-$day-access.log;