Replies: 2 comments 6 replies
-
Hello Christian, I tested the last version of Bref (FPM), and I guessed this is what you used if you are new to Bref. Here are my files and the output I got in the logs: # serverless.yml
service: bref-discussions-1371
provider:
name: aws
region: eu-west-3 # Paris, France. You might want to change it.
profile: perso # Note: optional, I handle multiple accounts
runtime: provided.al2
timeout: 10
layers:
- ${bref:layer.php-82-fpm}
plugins:
- ./vendor/bref/bref
functions:
hello:
handler: hello.php
events:
- httpApi: 'GET /hello'
error:
handler: error.php
events:
- httpApi: 'GET /error'
# Exclude files from deployment
package:
patterns:
- '!node_modules/**'
- '!tests/**' # hello.php
<?php
use Bref\Logger\StderrLogger;
require "vendor/autoload.php";
$logger = new StderrLogger();
$logger->error("This is an error");
$logger->notice("And a notice"); // won't be written in CloudWatch, default log level = "warning" # error.php
<?php
require "vendor/autoload.php";
$error =; {
"require": {
"bref/bref": "^1.7",
"bref/logger": "^1.0"
}
} And here's the console output for the logs: $ sls logs --function hello
[03-Jan-2023 10:18:12] NOTICE: fpm is running, pid 9
[03-Jan-2023 10:18:12] NOTICE: ready to handle connections
START
[ERROR] This is an error
END Duration: 23.17 ms (init: 306.18 ms) Memory Used: 67 MB
$ sls logs --function error
START
[03-Jan-2023 10:18:17] NOTICE: ready to handle connections
NOTICE: PHP message: PHP Parse error: syntax error, unexpected token ";" in /var/task/error.php on line 5
END Duration: 10.71 ms (init: 295.62 ms) Memory Used: 66 MB Did you try to look for the logs directly from your CLI? Or did you use the AWS Console? For the latter, you can find the logs in the Log Groups section of CloudWatch: Or directly inside the Lambda function you deployed: I hope this can help. If it doesn't, can you share a bit more code with us? Your serverless.yml file, the version of Bref you used, the version of the Serverless Framework you are running, etc. The more, the better 😉 Edit: added two comments in the |
Beta Was this translation helpful? Give feedback.
-
@afu-dev provided awesome details, I just want to point out this specific bit:
That's intriguing 🤔 This isn't something that I've seen before. Are you trying to use maybe Serverless Console's Dev Mode with Bref? It is possible that whatever extension this is, it disables the logs to CloudWatch entirely. |
Beta Was this translation helpful? Give feedback.
-
I'm new to serverless and bref. So excited about the possibilities!
But so far, I'm running blind: I'm not seeing PHP errors/warnings in CloudWatch.
The bref documentation says:
But this isn't working for me—or I'm not looking in the right place.
PHP Code
I intentionally put this error in my
public/index.php
file:Expected CloudWatch output
Output of an error to an undefined expression
xxx_require
.Actual CloudWatch output
Instead, I'm just seeing "stats" of the invocation…
Again: I'm expecting to see a PHP error lodged in the lines of logs above… somewhere… anywhere.
Am I looking in the wrong place? Doing something wrong? Expecting something wrong?
The Bref logger
I also tried invoking the bref logger [after a composer install] of it via this code in my
public/index.php
file:But I still don't see
This is an error
in the logs.Thanks for reading and any insight you might have. 😊
Beta Was this translation helpful? Give feedback.
All reactions