nginx 日志文件按日期记录

修改前

修改之前, 日志打印为: access_log logs/access.log main;
其中, mian 为前一行自定义的 log_format ;


修改后

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;
}
access_log  logs/$year-$month-$day-access.log  main;

你可能感兴趣的:(nginx 日志文件按日期记录)