What happens, when I have a maven application consisting of multiple modules and each of them contains a log4j.properties file, do they get merged or overwritten by a certain one (if yes, which one)?
Update: Following your advice I have now excluded the additional properties like this in my poms:
<dependency>
[...]
<excludes><exclude>**/log4j.properties</exclude></excludes>
</dependency>
P.S.: However, the "excludes" tag is not recognized by Maven and "exclusions" only works for dependencies, not resources.
Update
Just found out in log4j in a multi-module Maven project that I can just put the log4j.properties in src/test/resources so that they aren't included anyways in the executable module!.
The file is named log4j. properties and is located in the $DGRAPH_HOME/dgraph-hdfs-agent/lib directory. The file defines the ROLLINGFILE appenders for the root logger and also sets the log level for the file. The level of the root logger is defined as INFO and attaches the ROLLINGFILE appender to it.
java - A Maven plugin uses a library which logs with log4j - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.
Community support: Log4j 1. x is not actively maintained, whereas Log4j 2 has an active community where questions are answered, features are added and bugs are fixed. Automatically reload its configuration upon modification without losing log events while reconfiguring.
They never get merged. Generally, the log4j.properties files get overwritten and you can not exactly tell which one.
It depends on the sequence of loading the Jar files by container.
So It is recommended to have one log4j.properties with multiple appenders each for other sub-modules in the core module of your application.
But it would create problem while testing/working with sub-modules independently as it will stop logging when tested separately. In our case, the source control version of pom always used to exclude resource (which will exclude the properties file while building the jar). However in developer local, developers used to comment that exclusion in POM and can work independently.
For example if you have 2 projects one for data and another for presentation. And both have the log4j.properties. And when you deploy the war file which also contains the data file inside it. Only the presentation project has the effect. And the log4.properties in the data project would be ignored. They will never get merged or over written by itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With