1 Answer
- Newest
- Most votes
- Most comments
2
Hello.
By default, Lambda is configured to output logs to a log group named "/aws/lambda/<function name>".
https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html
By default, Lambda sends logs to a log group named /aws/lambda/<function name>. If you want your function to send logs to another group, you can configure this using the Lambda console, the AWS Command Line Interface (AWS CLI) or the Lambda API. See Configuring CloudWatch log groups to learn more.
Therefore, you need to set "LogGroup" in "LoggingConfig" of CloudFormation.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-loggingconfig.html#cfn-lambda-function-loggingconfig-loggroup
LambdaAdorationGroup7168EC0F:
Type: AWS::Lambda::Function
Properties:
Architectures:
- arm64
FunctionName: Dev-Project-Backend-Function
Handler: BackendFunction.lambda_handler
LoggingConfig:
ApplicationLogLevel: INFO
LogFormat: JSON
SystemLogLevel: DEBUG
LogGroup: Dev-Project-Backend-Log-Group-LogGroup # Add
MemorySize: 128
Role:
Fn::GetAtt:
- RoleLambdaExecReadWriteDB7DE264A3
- Arn
Runtime: python3.12
Timeout: 31
DependsOn:
- CloudWatchLogGroup9E01D9EC
- RoleLambdaExecReadWriteDB7DE264A3
Relevant content
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 5 months ago
With CDK, you can set it using the "logGroup" below. https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html
Thanks @Riku_Kobayashi. Once I saw your comment, I realised I have missed that "LogGroup" property in my code itself. It is fixed now. A silly mistake from my end