Logging using Log4J2 on aws lambda - Class not found

ぐ巨炮叔叔 提交于 2019-12-01 05:26:26

I also had this problem. It turns out that there is a typo bug in the AWS example documentation.

The packages in the <Configuration .. tag is wrong.

According to the log4j plugin configuration docs the packages parameter is a package not a class.

So modify your log4j2.xml configuration to be...

<?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="debug">
      <AppenderRef ref="Lambda" />
    </Root>
  </Loggers>
</Configuration>

Hope this helps. Cheers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!