I have a serverless.yml which contains definition and deployment for multiple lambdas and also the corresponding api gateway. However, I cannot get the log and log level to be applied to the lambda.
The below is added so that the log config. can be applied to all the lambdas, but it didn’t work.
provider:
name: aws
lambdaHashingVersion: 20201221
apiGateway:
minimumCompressionSize: 1024
runtime: nodejs16.x
memorySize: 512 # in MB, default is 1024
timeout: 10 # in seconds, default is 6
logRetentionInDays: ${file(./serverless_properties.yml):${self:provider.stage}.LOG_RETENTION_DAYS, "90"}
logs:
lambda:
logFormat: JSON
applicationLogLevel: ERROR
systemLogLevel: INFO
httpApi:
format: '{"request_id": "$context.requestId", "ip": "$context.identity.sourceIp", "requestTime":"$context.requestTime", "routeKey":"$context.routeKey", "status":"$context.status", "auth_error": "$context.authorizer.error", "error": "$context.error.message", "caller": "$context.identity.caller", "user": "$context.identity.user", "integration_error": "$context.integration.error" }'
I also tried the following; To configure the log level and stuff for a particular function, and it didn’t work as well.
functions:
get_releases_test_auth:
handler: main.GetReleases
events:
- httpApi:
method: get
path: "/test_auth/releases"
authorizer:
name: azure_ad_auth
logs:
# The Log Format to be used for all lambda functions (default: Text)
logFormat: JSON
# The Application Log Level to be used, This can only be set if `logFormat` is set to `JSON`
applicationLogLevel: ERROR
# The System Log Level to be used, This can only be set if `logFormat` is set to `JSON`
systemLogLevel: INFO
My framework version is defined as frameworkVersion: ^2.35.0 which I don’t think would be an issue, any help is really appreciated.