• 欢迎光临~

nginx自定义时间格式

开发技术 开发技术 2022-10-07 次浏览

在每个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"';

 

程序员灯塔
转载请注明原文链接:nginx自定义时间格式
喜欢 (0)