【中间件】nginx访问日志配置按天保存

    server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;
        if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
            set $year $1;
            set $month $2;
            set $day $3;
        }

        access_log logs/host-$year-$month-$day-access.log main;

在nginx.conf  里面的server中配置

        if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
            set $year $1;
            set $month $2;
            set $day $3;
        }

        access_log logs/host-$year-$month-$day-access.log main;

 

 

 

你可能感兴趣的:(nginx)