nginx 日志文件按日期记录

2020-04-02  本文已影响0人  离线中__

修改前

修改之前, 日志打印为: 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;
上一篇下一篇

猜你喜欢

热点阅读