在ExceptionHandler类中的render方法有记录日志,而TP框架在捕获异常的方法\think
\Error::appException()也记录了异常日志,这就会出现异常日志被记录了两个次。
比如我修改了model中的一个方法,这个方法是不存在的,错误被记录了两次。
1 2 3 | [ 2017-08-26T18:55:17+08:00 ] 127.0.0.1 127.0.0.1 GET /api/v1/banner/1 [ error ] [0]method not exist:think\db\Query->imgs [ error ] method not exist:think\db\Query->imgs |
HttpException异常也被记录了下来,而这个异常官网建议不要记录。应该把重构的render方法中记录日志的方法删除掉,这样就不会重复记录日志。
BaseException异常也记录到了日志里,覆盖ignoreReport属性,把不要写入日志的异常加入就可以,比如这样:
1 2 3 4 | protected $ignoreReport = [ '\\think\\exception\\HttpException' , '\\app\\lib\\exception\\BaseException' , ]; |
这是我在操作中的遇到的一些问题,不知道是否正确