How does Log4j manages multiple log4j.properties in its classpath? Which log4j.properties file takes precedence? Let me describe the exact scenario.
I have multiple maven modules developed by different teams and each one of them has its own log4j.properties file. All of these log4j.properties file have RootLogger configured along with ConsoleAppender and FileAppenders.
Now, when Log4j loads which log4j.properties file will it use to configure the RootLogger settings ? Also, how will Log4j create the Logger hierarchy ? How will the log4j.properties file in other 3rd party jars affect the logging process ?
The first file in the classpath will be loaded. So if A.jar and B.jar both contain a file, and A.jar comes before B.jar in the classpath, A.jar’s file will be loaded. That’s how the class loader works.