I already opened a thread on the AWS forums, so I’m going to refer to that page: https://forums.aws.amazon.com/message.jspa?messageID=814079#814079
I did some more testing and I updated the code, so that it doesn’t use the Log4j Logger anymore, but old fashioned System.out.println statements. Strangely enough, that “solved” the issue, as my log statements only appeared once, per invocation.
I didn’t change the log4j.properties file, so it still contains the default values:
log4j.rootLogger = DEBUG, LAMBDA
log4j.appender.LAMBDA=com.amazonaws.services.lambda.runtime.log4j.LambdaAppender
log4j.appender.LAMBDA.layout=org.apache.log4j.PatternLayout
log4j.appender.LAMBDA.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss} <%X{AWSRequestId}> %-5p %c:%L - %m%n
My Java knowledge is a bit rusty, but I can’t really see anything wrong with that configuration, at least that could declare why I see those log lines multiple times. Not sure if I stumbled upon some funky interpretation error between Lambda and Log4j.