【PHP】tp6错误日志,不显示文件和错误行数

一:开启记录堆栈信息

在/config/app.php,添加一行:
‘record_trace’ => true

<?php

// +----------------------------------------------------------------------
// | 日志设置
// +----------------------------------------------------------------------
return [
    // 默认日志记录通道
    'default'      => env('log.channel', 'file'),
    // 日志记录级别
    //debug, info, notice, warning, error, critical, alert, emergency,sql
    'level'        => ['error','critical', 'alert', 'emergency','warning'],
    // 日志类型记录的通道 ['error'=>'email',...]
    'type_channel' => [],
    // 关闭全局日志写入
    'close'        => false,
    // 全局日志处理 支持闭包
    'processor'    => null,
    //记录堆栈信息
    'record_trace' => true,
    // 日志通道列表
    'channels'     => [
        'file' => [
            // 日志记录方式
            'type'           => 'File',
            // 日志保存目录
            'path'           => '',
            // 单文件日志写入
            'single'         => false,
            // 独立日志级别
            'apart_level'    => [],
            // 最大日志文件数量
            'max_files'      => 0,
            // 使用JSON格式记录
            'json'           => false,
            // 日志处理
            'processor'      => null,
            // 关闭通道日志写入
            'close'          => false,
            // 日志输出格式化
            'format'         => '[%s][%s] %s',
            // 是否实时写入
            'realtime_write' => false,
        ],
        // 其它日志通道配置
    ],

];

二、查看日志

admin@kus: Creating default object from empty value
[2023-03-09T14:45:11+08:00][error] [62]Division by zero[/www/wwwroot/demo/app/admin/controller/Index.php:11]
[2023-03-09T14:50:48+08:00][error] [62]Division by zero[/www/wwwroot/demo/app/admin/controller/Index.php:11]
#0 /www/wwwroot/demo/app/admin/controller/Index.php(11): think\initializer\Error->appError()
#1 [internal function]: app\admin\controller\Index->index()
#2 /www/wwwroot/demo/vendor/topthink/framework/src/think/Container.php(343): ReflectionMethod->invokeArgs()
#3 /www/wwwroot/demo/vendor/topthink/framework/src/think/route/dispatch/Controller.php(110): think\Container->invokeReflectMethod()
#4 /www/wwwroot/demo/vendor/topthink/framework/src/think/Pipeline.php(59): think\route\dispatch\Controller->think\route\dispatch\{closure}()
#5 /www/wwwroot/demo/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->think\{closure}()
#6 /www/wwwroot/demo/vendor/topthink/framework/src/think/route/dispatch/Controller.php(113): think\Pipeline->then()
#7 /www/wwwroot/demo/vendor/topthink/framework/src/think/route/Dispatch.php(89): think\route\dispatch\Controller->exec()
#8 /www/wwwroot/demo/vendor/topthink/framework/src/think/Route.php(772): think\route\Dispatch->run()
#9 /www/wwwroot/demo/vendor/topthink/framework/src/think/Pipeline.php(59): think\Route->think\{closure}()
#10 /www/wwwroot/demo/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->think\{closure}()
#11 /www/wwwroot/demo/vendor/topthink/framework/src/think/Route.php(773): think\Pipeline->then()
#12 /www/wwwroot/demo/vendor/topthink/framework/src/think/Http.php(216): think\Route->dispatch()
#13 /www/wwwroot/demo/vendor/topthink/framework/src/think/Http.php(206): think\Http->dispatchToRoute()
#14 /www/wwwroot/demo/vendor/topthink/framework/src/think/Pipeline.php(59): think\Http->think\{closure}()
#15 /www/wwwroot/demo/vendor/topthink/think-multi-app/src/MultiApp.php(71): think\Pipeline->think\{closure}()
#16 /www/wwwroot/demo/vendor/topthink/framework/src/think/Pipeline.php(59): think\app\MultiApp->think\app\{closure}()
#17 /www/wwwroot/demo/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->think\{closure}()
#18 /www/wwwroot/demo/vendor/topthink/think-multi-app/src/MultiApp.php(72): think\Pipeline->then()
#19 [internal function]: think\app\MultiApp->handle()
#20 /www/wwwroot/demo/vendor/topthink/framework/src/think/Middleware.php(142): call_user_func()
#21 /www/wwwroot/demo/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->think\{closure}()
#22 /www/wwwroot/demo/vendor/topthink/think-trace/src/TraceDebug.php(71): think\Pipeline->think\{closure}()
#23 [internal function]: think\trace\TraceDebug->handle()
#24 /www/wwwroot/demo/vendor/topthink/framework/src/think/Middleware.php(142): call_user_func()
#25 /www/wwwroot/demo/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->think\{closure}()
#26 /www/wwwroot/demo/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->think\{closure}()
#27 /www/wwwroot/demo/vendor/topthink/framework/src/think/Http.php(207): think\Pipeline->then()
#28 /www/wwwroot/demo/vendor/topthink/framework/src/think/Http.php(170): think\Http->runWithRequest()
#29 /www/wwwroot/demo/public/index.php(20): think\Http->run()
#30 {main}

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值