You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to set the loglevel through an env var?
This would be especially useful for lambda-docker.
We would like to be able to filter out a lot of noise and only see our app logs, at least during development.
No this functionality is not currently within this open sourced code base. This is why I have left the ticket open.
This has been merged into the upstream repository within Amazon and the functionality will be made available upon the next synchronisation from Amazon's upstream repository.
We are currently using a Custom Container Image built on the Docker Hub Node image and followed the instructions in the documentation to download the emulator, install the Node runtime and run a ./entry.sh script
The runtime is working but currently the emulator exits immediately with a code 0 which from the code looks like what it does whenever it needs to shutdown but it currently fails to log any contextual information on why it's shutting down.
You can modify the entry.sh script to pass the log level as a command line argument, while waiting on being able to pass it as an environment variable to be synchronised.
E.g.
#!/bin/sh
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then
exec /usr/local/bin/aws-lambda-rie /usr/bin/npx aws-lambda-ric --log-level "trace"
else
exec /usr/bin/npx aws-lambda-ric
fi
You can see this is something AWS SAM would do on your behalf[1] if you were using it.
So I've added that flag and unfortunately it still just exits with a code 0 with no logs at all. I'll check out SAM but we already have an existing setup based around the serverless framework
In the end it turns out I was forgetting to tell curl to follow redirects and it was downloading an empty binary which in turn was being executed without any errors by the container instead of a invalid format error as I assume it was being treated as an empty executable shell script.
Activity
ghost commentedon Aug 10, 2022
Thank you for the suggestion barakbd.
It seems the default log level environment variable name in Go is
LOG_LEVEL
, is that what you would expect?ghost commentedon Aug 29, 2022
Thank you @barakbd for this suggestion.
We have merged functionality upstream to enable the providing of the log level via the environment variable
LOG_LEVEL
.This functionality will be available with the next merge from upstream. I will leave this ticket open until the next merge from upstream.
Thanks you!
jcampbell05 commentedon Nov 14, 2022
Has this been merge, I'm trying to debug why the RIE exits with a 0 code but I'm currently getting no logs to explain why.
Has no effect
ghost commentedon Nov 14, 2022
@jcampbell05 Sorry for the confusion.
No this functionality is not currently within this open sourced code base. This is why I have left the ticket open.
This has been merged into the upstream repository within Amazon and the functionality will be made available upon the next synchronisation from Amazon's upstream repository.
How are running your Lambda locally?
jcampbell05 commentedon Nov 14, 2022
We are currently using a Custom Container Image built on the Docker Hub Node image and followed the instructions in the documentation to download the emulator, install the Node runtime and run a ./entry.sh script
The runtime is working but currently the emulator exits immediately with a code 0 which from the code looks like what it does whenever it needs to shutdown but it currently fails to log any contextual information on why it's shutting down.
ghost commentedon Nov 14, 2022
You can modify the
entry.sh
script to pass the log level as a command line argument, while waiting on being able to pass it as an environment variable to be synchronised.E.g.
You can see this is something AWS SAM would do on your behalf[1] if you were using it.
jcampbell05 commentedon Nov 16, 2022
So I've added that flag and unfortunately it still just exits with a code 0 with no logs at all. I'll check out SAM but we already have an existing setup based around the serverless framework
jcampbell05 commentedon Nov 17, 2022
In the end it turns out I was forgetting to tell curl to follow redirects and it was downloading an empty binary which in turn was being executed without any errors by the container instead of a
invalid
format error as I assume it was being treated as an empty executable shell script.More details here:
nodejs/docker-node#1812
But please disregard my earlier comments.