标签:
直接在nginx配置文件中,配置日志循环,而不需使用logrotate或配置cron任务。需要使用到$time_iso8601 内嵌变量来获取时间。$time_iso8601格式如下:2015-08-07T18:12:02+02:00。然后使用正则表达式来获取所需时间的数据。
使用下面的代码块
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") { set $year $1; set $month $2; set $day $3; } access_log /data/logs/nginx/www.ttlsa.com-$year-$month-$day-access.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; }
标签:
原文地址:http://www.cnblogs.com/mingaixin/p/4719106.html