账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    Laravel选daily格式的日志,设置了days为什么没有按天删除旧的日志?
    47
    0
    days设置了1,按理来说应该只保存1天的日志吧?查看源码后发现vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.phppublic function __construct(string $filename, int $maxFiles = 0, $level = Logger::DEBUG, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false) { $this->filename = Utils::canonicalizePath($filename); $this->maxFiles = $maxFiles; $this->nextRotation = new \DateTimeImmutable('tomorrow'); $this->filenameFormat = '{filename}-{date}'; $this->dateFormat = static::FILE_PER_DAY; parent::__construct($this->getTimedFilename(), $level, $bubble, $filePermission, $useLocking); }protected function write(array $record): void { // on the first record written, if the log is new, we should rotate (once per day) if (null === $this->mustRotate) { $this->mustRotate = null === $this->url || !file_exists($this->url); } if ($this->nextRotation <= $record['datetime']) { $this->mustRotate = true; $this->close(); } parent::write($record); }这里的$this->nextRotation是明天的时间,会永远小于$record['datetime']吧?把if ($this->nextRotation <= $record['datetime'])这个判断去掉才能正常删除旧文件。是哪里的问题呢?
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 自我主宰 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部