Bugsnag + Laravel:使用 Log::error 传递上下文信息?

Bugsnag + Laravel: pass contextual information with Log::error?

调用 (Illuminate\Support\Facades\)Log::error 时,我只能在 Bugsnag 上看到消息,但看不到上下文信息。有什么方法可以设置 Laravel/Bugsnag 来传递上下文吗?

例如,当执行 Log::error("Exception occurred.", ["Further info here."]); 时,只有消息 ("Exception occurred.") 显示在 Bugsnag 上。

当您调用 Log::error 时,记录的消息和上下文由 Bugsnag PSR Logger 解析。以几种方式使用上下文:

  1. Extracts a title from the context array if set。此 title 将成为您的错误显示在 Bugsnag 仪表板上的上下文。
  2. Extracts an exception from the context array if setexception 然后将用于创建错误报告和堆栈跟踪。
  3. Attaches the remaining context to the report as metadata。如果 context 数组包含子数组,它们将显示在单独的选项卡上,否则信息将显示在 Bugsnag 仪表板上错误的 custom 选项卡中。

对于你的情况,我会检查你的错误的 custom 元数据选项卡,看看你的上下文是否出现在那里。