如何在 Laravel Telescope 中显示日志

问题描述 投票:0回答:1

我无法将日志保存到 Telescope_entries 表中,以便 Telescope 显示它们。

行动:

Log::channel('telescope')->debug('testing log:', ['variable' => $this->testVar]);

在 config/logging.php 中我定义了通道:

'telescope' => [
            'driver' => 'monolog',
            'handler' => FingersCrossedHandler::class,
            'level' => 'debug',
        ],

在 TelescopeServiceProvider.php 中,我已将 LOG 类型添加到过滤器中:

public function register(): void
    {
        Telescope::night();

        $this->hideSensitiveRequestDetails();

        $isLocal = $this->app->environment('local');
               
        Telescope::filter(function (IncomingEntry $entry) use ($isLocal) {
                        
            return $isLocal ||
                $entry->isReportableException() ||
                $entry->isFailedRequest() ||
                $entry->isFailedJob() ||
                $entry->isScheduledTask() ||
                $entry->hasMonitoredTag() ||
                $entry->type === EntryType::LOG;
        });
    }

我收到如下错误:

laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [telescope] is not defined.

我错过了什么?

laravel logging laravel-telescope
1个回答
0
投票

望远镜面板显示望远镜过滤器中定义的数据。对于日志和所有请求条目,只需将以下条件添加到过滤器中:

Telescope::filter(function (IncomingEntry $entry) use ($isLocal) {           
            return $isLocal ||
                $entry->isReportableException() ||
                $entry->isFailedRequest() ||
                $entry->isFailedJob() ||
                $entry->isScheduledTask() ||
                $entry->hasMonitoredTag() ||
 
                $entry->isLog() ||
                $entry->isRequest()||
        });
© www.soinside.com 2019 - 2024. All rights reserved.