通過$context引數讓tag生效,key必須是telescope,value必須是array,定義自己想要的標籤名稱;並且$context必須包含兩個引數,因為再Telescope原始碼vendor/laravel/telescope/src/Watchers/LogWatcher.php
會過濾key=telescope這個引數
public function recordLog(MessageLogged $event)
{
if (! Telescope::isRecording() || $this->shouldIgnore($event)) {
return;
}
Telescope::recordLog(
IncomingEntry::make([
'level' => $event->level,
'message' => (string) $event->message,
'context' => Arr::except($event->context, ['telescope']),
])->tags($this->tags($event))
);
}
正確生效的格式如下:
Log::info('測試tag',['telescope'=>['abc'],'xxx'=>'xxx']);
本作品採用《CC 協議》,轉載必須註明作者和本文連結