내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
해결됨

Use log4j 2.x.x with SLF4J on AEM 6.5.15

Avatar

Community Advisor

We are on AEM 6.5 with uber-jar-6.5.15

We are trying to use log4j 2.x.x in order to be able to use lambda expression in log statements. How can we achieve this?

주제

토픽은 커뮤니티 콘텐츠를 분류하여 관련성 있는 콘텐츠를 찾는 데 도움이 됩니다.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

@Kamal_Kishor 

 

I tested with below dependency and seems to be working.

             <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-slf4j-impl</artifactId>
                <version>2.23.1</version>          
            </dependency>
            <dependency>
                <groupId>com.adobe.aem</groupId>
                <artifactId>uber-jar</artifactId>
                <version>6.5.15</version>
            </dependency>

 

Can you test above and also check if you are using these dependencies in any other project's module where you need to update them.

 

-Tarun

원본 게시물의 솔루션 보기

3 답변 개

Avatar

Community Advisor

Hi @Kamal_Kishor ,

The Log4j 2 library has added support for Java 8 lambda expressions since version 2.4. These expressions can be used by the Logger interface to enable lazy logging.
What is the issue you are facing while using it? If there is anything of dependency conflict due to uber jar version then you can try to overwrite it by placing the dependency after uber jar.

 

-Tarun

Avatar

Community Advisor

I have added these into pom.xml after uber-jar dependency, still the version is not being reflected in bundles.

<!-- Log4j 2 API -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.23.1</version> <!-- Use the latest stable version -->
</dependency>
<!-- Log4j 2 Core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.23.1</version> <!-- Use the latest stable version -->
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>2.23.1</version>
</dependency>

 

Avatar

정확한 답변 작성자:
Community Advisor

@Kamal_Kishor 

 

I tested with below dependency and seems to be working.

             <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-slf4j-impl</artifactId>
                <version>2.23.1</version>          
            </dependency>
            <dependency>
                <groupId>com.adobe.aem</groupId>
                <artifactId>uber-jar</artifactId>
                <version>6.5.15</version>
            </dependency>

 

Can you test above and also check if you are using these dependencies in any other project's module where you need to update them.

 

-Tarun