nginx日志按日期存储

一定要按日期存储日志,不然日志文件会很大!!!!!

 

1.cd /usr/local/nginx/conf  //进入配置文件夹

2.编辑nginx.conf

在http下添加map{}和access_log

http {
    include       mime.types;
    default_type  application/octet-stream;
    map $time_iso8601 $logdate {
        '~^(?<ymd>\d{4}-\d{2}-\d{2})' $ymd;
        default    'date-not-found';
    }
    access_log logs/access-$logdate.log;

 

3.cd /usr/local/nginx/sbin

执行命令:

 ./nginx -s reload

  

 

posted @ 2022-07-14 17:36  今年我十八岁  阅读(1210)  评论(0编辑  收藏  举报