在每个server中加入:
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; }
在log日志格式中修改:
log_format main '$remote_addr - $remote_user [$year-$month-$day $hour:$minutes:$seconds] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
标签:set,http,自定义,month,nginx,year,格式 From: https://www.cnblogs.com/chensuqian/p/16759207.html