nginx 按天生成日志

月小升记得以前nginx没有办法读取日期,今天找到个办法居然可以。

server{
   location ~ \.php$ {
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }
        if ($time_iso8601 ~ '(\d{4}-\d{2}-\d{2})') {
            set $tttt $1;
        }
 
        access_log  /backup/wwwlogs/$tttt.java-er.com.log;
}

系统自动生成了2020-09-07.java-er.com.log文件


This entry was posted in Linux and tagged , , . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/nginx-log-daily/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.
2020.03.24 评论已经全局关闭,有事加QQ聊天