1

我正在尝试通过 Laravel Vapor 将 BugSnag 与部署在 AWS Lambda 上的 Laravel 应用程序集成。

Bugsnag 在我的本地运行良好,但没有从 AWS Lamda 发送任何错误。

我也试过 Bugsnag::setBatchSending(false) 但它仍然不适合我。

有什么想法可能是错的吗?

4

2 回答 2

7

Laravel Vapor 将默认日志配置更改为 stderr 通道,该通道由 AWS CloudWatch 捕获和记录。

使用包含 stderr 和 BugSnag 通道的堆栈驱动程序添加新的蒸汽通道对我有用。

在 .env.production 中

LOG_CHANNEL=vapor

在 config/logging.php

return [

    "channels" => [        

        "vapor" => [
            "driver" => "stack",
            "channels" => ["bugsnag", "stderr"],
            "ignore_exceptions" => false,
        ],

        "bugsnag" => [
            "driver" => "bugsnag",
        ],

    ],

];
于 2020-01-04T07:34:05.927 回答
1

接受的答案在排队作业中对我来说不能正常工作,仅适用于网络请求。

Taylor 在 Twitter 上评论说,最好在应用程序的错误处理程序中执行此操作 ( app/Exceptions/Handler.php)

public function report(Throwable $e)
{
    if (app()->environment() !== 'local') {
        Bugsnag::notifyException($e);
        Bugsnag::flush();
    }

    parent::report($e);
}

这样,异常会在 web、cli 和 queue 中正确报告。

于 2021-06-18T05:02:24.170 回答