【已找出问题所在,待解决】tp5中error日志记录关闭调试后没有详细信息啦怎么调

浏览:5173 发布日期:2016/12/08 分类:ThinkPHP5专区 关键字: tp5,调试日志
开着调试模式如果代码中有错会记录错误位置 ,关闭后只有个错误 提示没有详细信息位置 啦怎么配置都 不行
如图1里面是开着调试模式时有错误在哪个位置 2是关闭调试后就没有啦
已经找出原因:
在tp5中的Handle类中有这样的代码            // 收集异常数据
            if (App::$debug) {
                $data = [
                    'file'    => $exception->getFile(),
                    'line'    => $exception->getLine(),
                    'message' => $this->getMessage($exception),
                    'code'    => $this->getCode($exception),
                ];
                $log = "[{$data['code']}]{$data['message']}[{$data['file']}:{$data['line']}]";
            } else {
                $data = [
                    'code'    => $this->getCode($exception),
                    'message' => $this->getMessage($exception),
                ];
                $log = "[{$data['code']}]{$data['message']}";
            }

            Log::record($log, 'error');
        }
调试时记录详情,关闭后就简化啦,
一般情况下项目上线后也需要查看日志看看有没有错误,但不想开启调试模式
最佳答案
评论( 相关
后面还有条评论,点击查看>>