thinkphp5.1如何设置日志错误级别
2023-03-29 23:03:03
467
{{single.collect_count}}

thinkphp如何设置日志错误级别


TP5的错误级别很高,一些像未定义数组索引的错误都会进到错误日志,导致错误日志较多

如何修改日志错误级别

1、打开\thinkphp\library\think\Error.php

/** * 注册异常处理 * @access public * @return void */public static function register(){error_reporting(E_ALL);//修改下面这一行为set_error_handler([__CLASS__, 'appError']);//为如下这行set_error_handler([__CLASS__, 'appError'],E_ERROR | E_PARSE);set_exception_handler([__CLASS__, 'appException']);register_shutdown_function([__CLASS__, 'appShutdown']);}

set_error_handler 函数会绕过php本身的错误级别,所以这里php.ini的设置会无效

但是其它文章介绍的在common.php设置错误级别其实是起作用的,但是不会改变tp5的错误日志

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}