Nginx 启用日志分割

·347 Views·

配置如下:

1log_format main '$remote_addr - $remote_user [$time_local] "$request" '
2 '$status $body_bytes_sent "$http_referer" '
3 '"$http_user_agent" "$http_x_forwarded_for"';
4
5map $time_iso8601 $logdate {
6 '~^(?<ymd>\\d{4}-\\d{2}-\\d{2})' $ymd;
7 default 'date-not-found';
8}
9
10access_log logs/access-$logdate.log main;
11open_log_file_cache max=10;


参考:https://jingsam.github.io/2019/01/15/nginx-access-log.html