Log4j Logger problem

aws

#1

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.


#2

Did you ever figure this out? I’m seeing the same thing. It definitey has something to do with the configuration because if you don’t supply one it seems to work correctly (ish, using default log4j settings I guess).


#3

Not that I can’t remember. I handed it over to our API developers and they continued that journey.