I am using AWS Lambda with Java 8, and I am using Log4j2 Logger for printing logs in CloudWatch, following is my Log4j2 configuration.
<?xml version="1.0" encoding="UTF-8"?>
<Configuration packages="com.amazonaws.services.lambda.runtime.log4j2">
<Appenders>
<Lambda name="Lambda">
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss} %X{AWSRequestId} %-5p %c{1}:%L - %m%n</pattern>
</PatternLayout>
</Lambda>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Lambda"/>
</Root>
</Loggers>
</Configuration>
But CloudWatch is not printing AWSRequestId, as you can see in the following image, it looks like, if request ID is missing, then it is missing for all the logs for that request, and if the request ID shows up, it shows up for all the logs for that request (inside red box).
