AWS - Serverless: <4> Error Handler & Logging
- Anh Nguyen tuan
- Jul 8, 2022
- 1 min read
1. Error Handler
When lambda throw an Exception, it will push into the destination defined in DeadLetterQueue properties.
Using a lambda function to listen this queue and handle this error.

ErrorDLQueue:
Type: AWS::SNS::Topic
ConsumeMsgFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: customer
Handler: com.anhnt.customer.DeliverMsg::onSNSMessage
DeadLetterQueue:
Type: SNS
TargetArn: !Ref ErrorDLQueue2. Logging
Go to AWS service 'Cloud watch' to check logs:

For logging, you have 3 ways to log to 'cloud watch'
System.out.println;
LambdaLogger logger = context.getLogger();
Using Log4j library






Comments