• 导航

Nginx 启用日志分割

后端杂烩 记事本 2023-09-26 21 次浏览
配置如下:
      
  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

map $time_iso8601 $logdate {
'~^(?\d{4}-\d{2}-\d{2})' $ymd;
default 'date-not-found';
}

access_log logs/access-$logdate.log main;
open_log_file_cache max=10;