@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface Logging
Logging is used to signal that the annotated method should be
extended with Logging functionality.
Logging provides an opinionated logger with output structured as JSON.
Logging should be used with the handleRequest method of a class
which implements either
com.amazonaws.services.lambda.runtime.RequestHandler or
com.amazonaws.services.lambda.runtime.RequestStreamHandler.
By default Logging will load the following keys and values from the Lambda
com.amazonaws.services.lambda.runtime.Context
By default Logging will also create keys for:
These keys and values will be joined with the existing Log4J log event and written as JSON.
The data and time of the log event will be written using DateTimeFormatter.ISO_ZONED_DATE_TIME
By default Logging will not log the event which has trigger the invoke of the Lambda function.
This can be enabled using @Logging(logEvent = true).
By default Logging all debug logs will follow log4j2 configuration unless configured via
POWERTOOLS_LOGGER_SAMPLE_RATE environment variable @Logging(samplingRate = <0.0-1.0>).
To append additional keys to each log entry you can use LoggingUtils.appendKey(String, String)
| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
logEvent |
double |
samplingRate |
Copyright © 2021. All rights reserved.