我无法将日志保存到 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.
我错过了什么?
望远镜面板显示望远镜过滤器中定义的数据。对于日志和所有请求条目,只需将以下条件添加到过滤器中:
Telescope::filter(function (IncomingEntry $entry) use ($isLocal) {
return $isLocal ||
$entry->isReportableException() ||
$entry->isFailedRequest() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag() ||
$entry->isLog() ||
$entry->isRequest()||
});