I have a Maven POM file using org.apache.httpcomponents wich includes commons-logging (I don't need to include this dependency)
But I need to use Log4J, and it's causing conflicts by including commons-logging JAR and Log4J JARS in same project.
This conflict causing duplicating lines in my log file.
My POM (extract):
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-beta5</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-beta5</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-cache</artifactId>
<version>4.2.3</version>
</dependency>
I try to put an exclusion tag in org.apache.httpcomponents for commons-loggin, but I got a Runtime error in HttpClient class (no compile error).
What can I do?
Well, my fault!
Seems the specific class logger is stacked with root logger.
First log line is for specific class logger ( the logger called by class name ) and second line (duplicate) is for root logger. This is my log4j XML config:
<loggers>
<Logger name="cmabreu.sagitarii.teapot.Main" level="debug">
<appender-ref ref="File"/>
</Logger>
<root level="error">
<appender-ref ref="File" />
</root>
</loggers>
I need to add additivity="false"
for specific logger (cmabreu.sagitarii.teapot.Main), this way it will not stack with root logger.
<Logger name="cmabreu.sagitarii.teapot.Main" level="debug" additivity="false">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.