'AWS Lambda Logging log4j2.properites
I am trying to write log4j2 configuration using log4j2.properties to log to cloudwatch. The configuration using log4j2.xml is working but the configuration via log4j2.properties is not working. Below is my log4j2.properties *
packages=com.amazonaws.services.lambda.runtime.log4j2
appenders=Lambda
appender.Lambda.type=Lambda
appender.Lambda.name = Lambda
appender.Lambda.layout.type=org.apache.log4j.PatternLayout
appender.Lambda.layout.pattern=%d{yyyy-MM-dd HH:mm:ss} <%X{AWSRequestId}> %-5p %c{1}:%m%n
rootLogger.level = debug
rootLogger.appenderRefs = Lambda
rootLogger.appenderRef.Lambda.ref = Lambda
Has anybody tried to configure using properties file? I am getting the below error in Cloudwatch
ERROR Unable to invoke factory method in class
com.amazonaws.services.lambda.runtime.log4j2.LambdaAppender for element
Lambda: java.lang.IllegalStateException: No factory method found for
class com.amazonaws.services.lambda.runtime.log4j2.LambdaAppender
java.lang.IllegalStateException: No factory method found for class
com.amazonaws.services.lambda.runtime.log4j2.LambdaAppender
Solution 1:[1]
Add the dependency for that appender
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-log4j</artifactId>
<version>1.0.0</version>
<scope>runtime</scope>
</dependency>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sambhav. K |
