Logging

Logging for an AWS Lambda Java function can easily be set up with it. Logging helps to trace execution paths and troubleshoot issues, and generally, it provides insight on how the code is behaving.

Each statement to log creates an AWS CloudWatch event. You can find the logs in the console. Also, for the synchronous execution of functions via the Lambda console, one can find the logs right there.

There are two methods for having a logging solution set up in your AWS Lambda code, as follows:

  • Using Log4j2: Log4j2 is a widely used logging library, used in the JVM world. To configure logging for the Lambda function using Log4j2, the following settings are required.

It will require the following artifacts on the classpath of the deployment ...

Get Hands-On Serverless Applications with Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.