我正在尝试激活我的Apache HttpClient的调试日志记录,但无法使其工作(没有与HttpClient相关的日志输出)。
这是我目前正在使用的log4j2配置:
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="OFF">
<appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss} [%t] %-5level %logger{36} - %msg%n" />
</Console>
<RollingFile name="RollingRandomAccessFile" fileName="logs/test.log" filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>
%d %p %c{1.} [%t] %m%n
</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="10 MB" />
</Policies>
<DefaultRolloverStrategy max="20" />
</RollingFile>
<Async name="async">
<AppenderRef ref="RollingRandomAccessFile" />
</Async>
</appenders>
<loggers>
<logger name="org.apache.http.wire" level="debug" />
<logger name="org.apache.http.client" level="debug" />
<logger name="org.apache.xerces.parsers.SAXParser" level="warn" />
<logger name="org.hibernate" level="warn" />
<root level="trace">
<appender-ref ref="console" />
<appender-ref ref="async" />
</root>
</loggers>
</configuration>
对于hibernate来说,将日志级别从warn改为debug是完全可行的。
我正在使用以下这些库:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<version>4.2.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-cache</artifactId>
<version>4.2.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.2.6</version>
</dependency>
Log4J2
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-beta9</version>
</dependency>
有人有想法吗?我已经尝试了不同的包名,例如:
httpclient.wire
httpclient.wire.header
httpclient.wire.content
还有一些其他的尝试,但似乎都不起作用...