user12978881
user12978881

Reputation: 33

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?

Upvotes: 3

Views: 2607

Answers (2)

Aeonmarky
Aeonmarky

Reputation: 21

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);
}

Upvotes: 2

Maximiliano Chiale
Maximiliano Chiale

Reputation: 369

I am implementing the same these days and it work correctly.

did you add LOG_CHANNEL=stderr to the .env? does the user have permission to write in aws?

Upvotes: 0

Related Questions