1

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?

Vikas Roy
  • 854
  • 2
  • 10
  • 25

2 Answers2

7

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",
        ],

    ],

];
Vikas Roy
  • 854
  • 2
  • 10
  • 25
  • does this work for you on web/cli/queue? We are doing the same with custom cloudwatch logs, yet doesn't work on queue but does on web/cli. Does yours work on all? – Matt The Ninja Feb 26 '21 at 10:35
  • If you set batch settings to false, queue jobs seem to report to Bugsnag. Set BUGSNAG_BATCH_SENDING=false in your environment. – Joe Magaro Jan 22 '22 at 19:42
3

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.

atymic
  • 3,093
  • 1
  • 13
  • 26