Problem
Log4j2 logging no longer works after upgrading to com.amazonaws:aws-lambda-java-log4j2:1.6.3.
Log4j prints the error ERROR Error processing element Lambda ([Appenders: null]): CLASS_NOT_FOUND to stderr (which is not logged by lambda).
Reproduction Steps
- Create a new maven project as described below
- Execute the code via
mvn package exec:java -Dexec.mainClass="bug.reproduction.App"
Reproduction Files
./pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>bug.reproduction</groupId>
<artifactId>aws-lambda-java-log4j2</artifactId>
<version>1.0-SNAPSHOT</version>
<name>aws-lambda-java-log4j2</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-log4j2</artifactId>
<version>1.6.3</version> <!-- 1.6.2 works -->
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.25.4</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.25.4</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-layout-template-json</artifactId>
<version>2.25.4</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifest>
<mainClass>bug.reproduction.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
./src/main/java/bug/reproduction/App.java
package bug.reproduction;
import org.apache.logging.log4j.LogManager;
/**
* Hello world!
*/
public class App {
public static void main(String[] args) {
System.out.println("Should print test below");
LogManager.getLogger("foo").info("test");
System.out.println("Should have print test above");
}
}
./src/main/resources/log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Lambda name="Console">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1} - %m%n"/>
</Lambda>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
Expected Output
[INFO] Scanning for projects...
[INFO]
[INFO] --------------< bug.reproduction:aws-lambda-java-log4j2 >---------------
[INFO] Building aws-lambda-java-log4j2 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ aws-lambda-java-log4j2 ---
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO]
[INFO] --- compiler:3.13.0:compile (default-compile) @ aws-lambda-java-log4j2 ---
[INFO] Nothing to compile - all classes are up to date.
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ aws-lambda-java-log4j2 ---
[INFO] skip non existing resourceDirectory /Users/bnd/reproduction/aws-lambda-java-log4j2/src/test/resources
[INFO]
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ aws-lambda-java-log4j2 ---
[INFO] No sources to compile
[INFO]
[INFO] --- surefire:3.5.4:test (default-test) @ aws-lambda-java-log4j2 ---
[INFO] No tests to run.
[INFO]
[INFO] --- jar:3.4.2:jar (default-jar) @ aws-lambda-java-log4j2 ---
[INFO]
[INFO] --- exec:3.6.3:java (default-cli) @ aws-lambda-java-log4j2 ---
Should print test below
2026-05-19 12:18:10 INFO foo - test
Should have print test above
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.776 s
[INFO] Finished at: 2026-05-19T12:18:10-04:00
[INFO] ------------------------------------------------------------------------
To reproduce expected output, update line 21 in ./pom.xml to <version>1.6.2</version>
Actual Output
[INFO] Scanning for projects...
[INFO]
[INFO] --------------< bug.reproduction:aws-lambda-java-log4j2 >---------------
[INFO] Building aws-lambda-java-log4j2 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ aws-lambda-java-log4j2 ---
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO]
[INFO] --- compiler:3.13.0:compile (default-compile) @ aws-lambda-java-log4j2 ---
[INFO] Nothing to compile - all classes are up to date.
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ aws-lambda-java-log4j2 ---
[INFO] skip non existing resourceDirectory /Users/bnd/reproduction/aws-lambda-java-log4j2/src/test/resources
[INFO]
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ aws-lambda-java-log4j2 ---
[INFO] No sources to compile
[INFO]
[INFO] --- surefire:3.5.4:test (default-test) @ aws-lambda-java-log4j2 ---
[INFO] No tests to run.
[INFO]
[INFO] --- jar:3.4.2:jar (default-jar) @ aws-lambda-java-log4j2 ---
[INFO] Building jar: /Users/bnd/reproduction/aws-lambda-java-log4j2/target/aws-lambda-java-log4j2-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- exec:3.6.3:java (default-cli) @ aws-lambda-java-log4j2 ---
Should print test below
2026-05-19T16:19:47.710360Z bug.reproduction.App.main() ERROR Error processing element Lambda ([Appenders: null]): CLASS_NOT_FOUND
2026-05-19T16:19:47.720281Z bug.reproduction.App.main() ERROR Unable to locate appender "Console" for logger config "root"
Should have print test above
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.038 s
[INFO] Finished at: 2026-05-19T12:19:47-04:00
[INFO] ------------------------------------------------------------------------
Note that the two bug.reproduction.App.main() ERROR lines are written to stderr, as evidenced by running it while redirecting stderr to /dev/null via mvn package exec:java -Dexec.mainClass="bug.reproduction.App" 2> /dev/null
Problem
Log4j2 logging no longer works after upgrading to
com.amazonaws:aws-lambda-java-log4j2:1.6.3.Log4j prints the error
ERROR Error processing element Lambda ([Appenders: null]): CLASS_NOT_FOUNDto stderr (which is not logged by lambda).Reproduction Steps
mvn package exec:java -Dexec.mainClass="bug.reproduction.App"Reproduction Files
./pom.xml./src/main/java/bug/reproduction/App.java./src/main/resources/log4j2.xmlExpected Output
To reproduce expected output, update line 21 in
./pom.xmlto<version>1.6.2</version>Actual Output
Note that the two
bug.reproduction.App.main() ERRORlines are written to stderr, as evidenced by running it while redirecting stderr to/dev/nullviamvn package exec:java -Dexec.mainClass="bug.reproduction.App" 2> /dev/null