Maven build [WARNING] we have a duplicate class

Take a look at the “Dependency Exclusions” section in the Maven doc. In your provided example, I’ll exclude the commons-logging:commons-logging-api:jar:1.0.4:compile dependency from org.apache.hadoop.hive:hive-common:jar:0.7.1-cdh3u3:compile. In your pom.xml : <dependency> <groupId>org.apache.hadoop.hive</groupId> <artifactId>hive-common:jar</artifactId> <version>0.7.1-cdh3u3</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> </exclusion> </exclusions> </dependency>

Turning on Logging in HttpClient

I faced same problem today. And I found out a solution for this problem. It’s pretty simple. Just add jcl-over-slf4j dependency to forward JCL logging (Apache Commons Logging) to slf4j. <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>1.7.5</version> </dependency> After that you can config log file as Log4j Examples. If you use logback you can put the following to … Read more

Difference between Simple Logging Facade for Java and Apache Commons Logging

From the SLF4J FAQ: SLF4J is conceptually very similar to JCL. As such, it can be thought of as yet another logging facade. However, SLF4J is much simpler in design and arguably more robust. In a nutshell, SLF4J avoid the class loader issues that plague JCL. Do a google for “JCL classloader issues” for more … Read more

What is the issue with the runtime discovery algorithm of Apache Commons Logging

Why? What is the issue with its runtime discovery algorithm? Performance? No, it’s not performance, it’s classloader pain. JCL discovery process relies on classloader hacks to find the logging framework at runtime but this mechanism leads to numerous problems including unexpected behavior, hard to debug classloading problems resulting in increased complexity. This is nicely captured … Read more

Java Logging: show the source line number of the caller (not the logging helper method)

Alternative answer. It is possible to ask log4j to exclude the helper class by using the method Category.log(String callerFQCN, Priority level, Object message, Throwable t) and specifying the helper class as ‘callerFQCN’. For example here is a class using a helper: public class TheClass { public static void main(String…strings) { LoggingHelper.log(“Message using full log method … Read more

What is the significance of log4j.rootLogger property in log4j.properties file? What happens if I don’t use this property?

Samudra Gupta explains in his book1: The Logger object is the main object that an application developer uses to log any message. The Logger objects acting within a particular instance of an application follow a parent-child hierarchy. If you have the following configuration: log4j.rootLogger=WARN, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout log4j.logger.com.me.proj2=INFO This is how the logger hierarchy could … Read more

tech