Problems exposing HTTP client logs through Log4j2. I was able to expose the logs with log4j v1, but it's not working with log4j2.
Checked the transactive dependencies of http client v4 and it uses common logging. So I passed log4j-jcl.jar at runtime since its a bridge. But it's not working
Dependencies used:
Http Dependencies:
<dependency>
<groupId>com.dictao.util</groupId>
<artifactId>dictao-util-net</artifactId>
<version>${dictao.common.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.6</version>
</dependency>
Bridge Dependency:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>2.11.2</version>
<scope>runtime</scope>
</dependency>
For Log4j1:
log4j.logger.org.apache.http.impl.conn=DEBUG
log4j.logger.org.apache.http.impl.client=DEBUG
log4j.logger.org.apache.http.client=DEBUG
log4j.logger.org.apache.http=DEBUG
Passing the same thing in Log4j2,but no result.
Output: No error and no log file is generated.
答案 0 :(得分:1)
您需要将log4j-core
添加到您的依赖项中
Log4j2分为api和核心模块(而log4j1是单语言的)。
添加桥依赖项时,仅可传递地仅获取log4j2 api,但没有实际的日志记录引擎(log4j-core
模块)。
支持我的话:http://central.maven.org/maven2/org/apache/logging/log4j/log4j-jcl/2.11.2/log4j-jcl-2.11.2.pom