Vikas Roy
Vikas Roy

Reputation: 864

BugSnag not working for Laravel Vapor in production

I am trying the BugSnag integration with a Laravel app deployed on AWS Lambda through Laravel Vapor.

Bugsnag is working fine on my local but doesn’t send any error from AWS Lamda.

I also tried Bugsnag::setBatchSending(false) but it is still not working for me.

Any ideas what can be wrong?

Upvotes: 1

Views: 1357

Answers (2)

atymic
atymic

Reputation: 3128

The accepted answer didn't work correctly for me in queued jobs, only for web requests.

Taylor commented on twitter that it's best to do this in your application's error handler (app/Exceptions/Handler.php)

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

    parent::report($e);
}

This way, exceptions are correctly reported in web, cli and queue.

Upvotes: 3

Vikas Roy
Vikas Roy

Reputation: 864

Laravel Vapor changes default logging configuration to the stderr channel, which is captured and logged by AWS CloudWatch.

Adding a new vapor channel using the stack driver that includes both the stderr and BugSnag channels worked for me.

In .env.production

LOG_CHANNEL=vapor

In config/logging.php

return [

    "channels" => [        

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

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

    ],

];

Upvotes: 7

Related Questions