nginx默认的日志是写在一个文件access.log里的,时间久了就会很大,大到无法打开
全网搜索找到了这个方法,如下图:
代码如下:
log_format access-upstream '$time_iso8601|$request|$remote_addr|$upstream_response_time|$http_user_agent|$http_x_forwarded_for';
map $time_iso8601 $logdate {
'~^(?<ymd>\d{4}-\d{2}-\d{2})' $ymd;
default 'date-not-found';
}
access_log logs/access-$logdate.log ;