Multimodular pom with different logback.xml per module

I have a 2-module pom, and ideally I would like each submodule to have its own logback.xml file. But logback complains about finding more than one logback.xml file in the classpath. Although it seems like this is not a problem and the correct xml has been picked up, I would like to know what is the best solution for this.

Thanks in advance!

+6
source share
1 answer

If your module is a jar that will be included as a dependency by another module, you should not have a logback.xml file - it depends on the user of the jar to determine the logging configuration. Also, you should not specify logback as a dependency, as the user must choose the implementation of logging.

I assume that one of your two modules depends on the other. Thus, the dependent module should have logback.xml, and the other should not.

When unit testing each module, you can put logback-test.xml in src/test/resources and add a login as a function of the test area. Thus, it will not be displayed as a module dependency, and the log XML file will not be exported.

+9
source

Source: https://habr.com/ru/post/907769/


All Articles