Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel, logging and Cloudwatch - why isn't this working?

I'm currently using Laravel 6.16.0.

We are trying to get extensive logging on our application. The Package we have installed is: https://github.com/maxbanton/cwh, and I'm using this to implement it: https://stackoverflow.com/a/51790656/12978881

We're using Stacks for our logging, which includes Slack, Sentry, Laravel logs and CW.

For some reason it just isn't outputting anything to CloudWatch which we want to be the main output.

In the CloudWatchLoggerFactory.php I've even tried throwing any AWS errors like so:

try {
      $handler = new CloudWatch($client, $groupName, $streamName, $retentionDays, 10000, $tags);
} catch(\Exception $e) {
      print_r($e);
}

However nothing is even getting that far.

The code is definitely being invoked as it exits with a simple die('test.');

No errors relating to AWS are being output to the log at all. The AWS keys are valid and have the correct permissions.

Has anyone had a similar experience, and how did you sort it?

like image 990
user12978881 Avatar asked Dec 11 '25 22:12

user12978881


1 Answers

Try setting the buffer size to 0 like this

try {
      $handler = new CloudWatch($client, $groupName, $streamName, $retentionDays, 0, $tags);
} catch(\Exception $e) {
      print_r($e);
}
like image 186
Aeonmarky Avatar answered Dec 13 '25 10:12

Aeonmarky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!