Log4j.properties in multiple maven modules?

What happens when I have a maven application consisting of several modules, and each of them contains a log4j.properties file, are they combined or overwritten by a specific one (if so, which one)?

Update. Following your advice, I have now ruled out additional properties like this in my poses:

<dependency> [...] <excludes><exclude>**/log4j.properties</exclude></excludes> </dependency> 

PS: However, the exclude tag is not recognized by Maven, and the exceptions only work for dependencies, not resources.

Update

I just found out in log4j in the Maven multi- module project that I can just put log4j.properties in src / test / resources so that they are not included in the executable module anyway!

+6
source share
2 answers

They never merge. Typically, log4j.properties files are overwritten, and you cannot determine exactly which one.

It depends on the sequence of loading the jar files by the container.

Therefore, it is recommended that you have one log4j.properties with several add-ons for other submodules in the main module of your application.

But this will create a problem while testing / working with submodules at the same time, regardless of how it stops logging during testing separately. In our case, the original version of pom was always used to exclude the resource (which will exclude the properties file when building the jar). However, in the local developer, the developers commented on this exception in the POM and can work independently.

+6
source

For example, if you have 2 projects, one for data and another for presentation. And both have log4j.properties. And when you deploy a military file that also contains a data file inside it. Only a project presentation has an effect. And log4.properties in the data project will be ignored. They will never be merged or written on their own.

+1
source

All Articles