0
votes

I have java maven project with below structure

AA.ear
|_ lib
    |_ parent_config.jar
       |_ log4j.xml
    |_ child_config.jar
       |_ log4j.xml [this is expeccted to load]
|_ BB.war


I am using log4j 1.2. For parent_config.jar is dependency project which inherit by child_config.jar. Both of them have log4j.xml. Classloader read log4j.xml from child_config.jar all the time but since upgraded to Spring 4, it does not work as expected. It turns out load log4j.xml from parent_config.xml.

I tried remove log4j.xml from parent_config.jar by 7zip and at the end it works as expected. Moreover, the limitation here is I should build parent_config.jar as usual (without remove log4j.xml) because it used by other project also. And excluded approaches of using WEB-INF/lib and -Dlog4j.configuration

May I know is there any suggestion on this situation?

1

1 Answers

0
votes

Within some runtime environments, it may be possible to control the order of classpath entries. But I wouldn't recommend that.

You should provide a custom log4j configuration file with a different name then log4j.xml and/or not located in the classpath root and configure it via the system property log4j.configuration.