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

时间:2018-06-01 10:59:43

标签: laravel bugsnag

调用(Illuminate\Support\Facades\)Log::error时,我只能看到Bugsnag上的消息,但不会看到上下文信息。我有没有办法设置Laravel / Bugsnag来传递上下文?

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

1 个答案:

答案 0 :(得分:3)

当您致电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 set。然后,此exception将用于创建错误报告和堆栈跟踪。
  3. Attaches the remaining context to the report as metadata。如果context数组包含子数组,它们将显示在单独的选项卡上,否则信息将显示在Bugsnag仪表板错误的custom选项卡中。
  4. 在您的情况下,我会查看您的错误的custom元数据标签,看看您的背景是否出现在那里。