Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multi module pom with different logback.xml per module

Tags:

maven

logback

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 files in the classpath. Although it seems as if this is not a problem and the right xml is picked up, I would like to know what is the best solution for this.

Thanks in advance!

like image 725
gpol Avatar asked Feb 06 '12 13:02

gpol


1 Answers

If your module is a jar, to be included as a dependency by another module, you shouldn't really have a logback.xml - it's up to the user of the jar to decide their logging configuration. Nor should you list logback as a dependency, since the user should choose the logging implementation.

I assume one of your two modules depends on the other. So the dependent module should have the logback.xml, and the other shouldn't.

While unit-testing each module, you can put a logback-test.xml in src/test/resources and add logback as a test-scoped dependency. That way, it won't be listed as a dependency of the module and the logback xml file won't be exported.

like image 60
artbristol Avatar answered Sep 27 '22 22:09

artbristol