framework icon indicating copy to clipboard operation
framework copied to clipboard

解决当 apart_level 的日志文件数量大于 max_files 时,日志文件不但不会生成,还有可能会被莫名删除的问题

Open RiverDanceGit opened this issue 3 years ago • 2 comments

RiverDanceGit avatar Jun 27 '22 15:06 RiverDanceGit

这两者貌似没直接关系吧 而且apart_level的值是有可能为true的

liu21st avatar Jul 05 '22 05:07 liu21st

这两者貌似没直接关系吧 而且apart_level的值是有可能为true的

第一步:如下配置 config/log.php

'channels'     => [
    'file' => [
        ......
        'apart_level'    => ['error', 'warning', 'sql', 'emergency', 'alert', 'critical', 'notice', 'info', 'debug'],
        'max_files'      => 1,
        ......
    ]
]

第二步:清空日志目录里的所有文件

第三步:运行代码,注意,代码里需要同时存在各种级别的日志输出,如下:

Log::info("测试日志1");
Log::error("测试日志2");
Log::debug("测试日志3");
Log::sql("测试日志4");

第四步:进入日志目录里,发现只有一个日志文件,本来预期有 4 个文件

年月日_info.log
年月日_error.log
年月日_debug.log
年月日_sql.log

apart_level 如果存在为 true 的情况,那这 pr 是还有点问题,先不用合并了。

RiverDanceGit avatar Jul 14 '22 15:07 RiverDanceGit