单文件存放,后面还需要定期手工切割,在配置中设备按日期自动分开存放比较好。
按日期分割
server {
listen 80;
server_name abc.com;
#.....中间省略
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
set $date $1$2$3;
}
access_log /home/wwwlogs/$date.$server_name.log;
}
精细分割
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})")
{
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
set $minutes $5;
set $seconds $6;
}