Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat!: remove log4j #995

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ Powertools is available in Maven Central. You can use your favourite dependency
<dependency>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-tracing</artifactId>
<version>1.12.3</version>
<version>2.0.0-beta</version>
</dependency>
<dependency>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-logging</artifactId>
<version>1.12.3</version>
<version>2.0.0-beta</version>
</dependency>
<dependency>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-metrics</artifactId>
<version>1.12.3</version>
<version>2.0.0-beta</version>
</dependency>
...
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ extra_javascript:

extra:
powertools:
version: 1.12.3
version: 2.0.0-beta

repo_url: https://github.com/awslabs/aws-lambda-powertools-java
edit_uri: edit/master/docs
21 changes: 20 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-parent</artifactId>
<version>1.12.3</version>
<version>2.0.0-beta</version>
<packaging>pom</packaging>

<name>AWS Lambda Powertools for Java library Parent</name>
Expand All @@ -30,6 +30,8 @@
<module>powertools-core</module>
<module>powertools-serialization</module>
<module>powertools-logging</module>
<module>powertools-logging-log4j</module>
<module>powertools-logging-logback</module>
<module>powertools-tracing</module>
<module>powertools-sqs</module>
<module>powertools-metrics</module>
Expand All @@ -56,6 +58,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<log4j.version>2.19.0</log4j.version>
<slf4j.version>2.0.4</slf4j.version>
<jackson.version>2.14.1</jackson.version>
<aspectj.version>1.9.7</aspectj.version>
<aws.sdk.version>2.18.22</aws.sdk.version>
Expand All @@ -77,6 +80,7 @@
<junit-jupiter.version>5.9.1</junit-jupiter.version>
<aws-embedded-metrics.version>1.0.6</aws-embedded-metrics.version>
<jmespath.version>0.5.1</jmespath.version>
<elastic.version>1.5.0</elastic.version>
</properties>

<distributionManagement>
Expand Down Expand Up @@ -175,6 +179,11 @@
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
Expand All @@ -190,6 +199,16 @@
<artifactId>log4j-jcl</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>co.elastic.logging</groupId>
<artifactId>logback-ecs-encoder</artifactId>
<version>${elastic.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-xray-recorder-sdk-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion powertools-cloudformation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<artifactId>powertools-parent</artifactId>
<groupId>software.amazon.lambda</groupId>
<version>1.12.3</version>
<version>2.0.0-beta</version>
</parent>

<name>AWS Lambda Powertools for Java library Cloudformation</name>
Expand Down
2 changes: 1 addition & 1 deletion powertools-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<artifactId>powertools-parent</artifactId>
<groupId>software.amazon.lambda</groupId>
<version>1.12.3</version>
<version>2.0.0-beta</version>
</parent>

<name>AWS Lambda Powertools for Java library Core</name>
Expand Down
2 changes: 1 addition & 1 deletion powertools-idempotency/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-parent</artifactId>
<version>1.12.3</version>
<version>2.0.0-beta</version>
</parent>

<artifactId>powertools-idempotency</artifactId>
Expand Down
118 changes: 118 additions & 0 deletions powertools-logging-log4j/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?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>

<parent>
<artifactId>powertools-parent</artifactId>
<groupId>software.amazon.lambda</groupId>
<version>2.0.0-beta</version>
</parent>

<artifactId>powertools-logging-log4j</artifactId>
<packaging>jar</packaging>

<name>AWS Lambda Powertools for Java library Logging with Log4j2</name>
<description>
A suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray, structured logging and creating custom metrics asynchronously easier.
</description>
<url>https://aws.amazon.com/lambda/</url>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/awslabs/aws-lambda-powertools-java/issues</url>
</issueManagement>
<scm>
<url>https://github.com/awslabs/aws-lambda-powertools-java.git</url>
</scm>
<developers>
<developer>
<name>AWS Lambda Powertools team</name>
<organization>Amazon Web Services</organization>
<organizationUrl>https://aws.amazon.com/</organizationUrl>
</developer>
</developers>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://aws.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-logging</artifactId>
<version>${version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-layout-template-json</artifactId>
<scope>provided</scope>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-tests</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package software.amazon.lambda.powertools.logging.internal;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configurator;
import org.slf4j.Logger;

public class Log4jLoggingManager implements LoggingManager {

@Override
public void resetLogLevel(org.slf4j.event.Level logLevel) {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configurator.setAllLevels(LogManager.getRootLogger().getName(), Level.getLevel(logLevel.toString()));
ctx.updateLoggers();
}

@Override
public org.slf4j.event.Level getLogLevel(Logger logger) {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
return org.slf4j.event.Level.valueOf(ctx.getLogger(logger.getName()).getLevel().toString());
}


}
Loading