@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface PowertoolsLogging
PowertoolsLogging is used to signal that the annotated method should be
extended with PowertoolsLogging functionality.
PowertoolsLogging provides an opinionated logger with output structured as JSON.
PowertoolsLogging 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 PowertoolsLogging will load the following keys and values from the Lambda
com.amazonaws.services.lambda.runtime.Context
By default PowertoolsLogging 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 PowertoolsLogging will not log the event which has trigger the invoke of the Lambda function.
This can be enabled using @PowertoolsLogging(logEvent = true).
By default PowertoolsLogging all debug logs will follow log4j2 configuration unless configured via
POWERTOOLS_LOGGER_SAMPLE_RATE environment variable @PowertoolsLogging(samplingRate = <0.0-1.0>).
To append additional keys to each log entry you can use PowertoolsLogger.appendKey(String, String)
| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
logEvent |
double |
samplingRate |
Copyright © 2020. All rights reserved.