Scenario I have:
project --> libA --> libB
project uses libA (imported in pom), libA uses libB.
Due to other constrains, in project pom I exclude everything from libA and then I import manually libB.
Both libA and libB are maintained by me but are extracted as librarie for reusability. Project and libB have as parent the sprig-boot-parent. libA is a maven project (no parent) that contains spring libraries.
If I put logback.xml file in all of them (project, libA, libB), then I receive an warning:
13:20:26,442 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath.
Additional to above log, there are other lines of log that I don't desire.
If I put logback.xml in project and in libB, then I don't receive the above warning. The logs in the project and libB is formated correctly but not the one in libA
In the end I want to have the same log format for all of them without other unwanted logs.
How can I cofigure logback so that it will apply also to the library and transitive libraries ? What are the recommendations in these types of scenarios?
Later edit:
Adding logback config that is applied in the project:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<Target>System.out</Target>
<encoder>
<pattern>D:%d{yyyy-MM-dd HH:mm:ss.SSS} L:%p C:%c{1} F:%F\(%L\) Fn:%M T:%thread R:%X{R} - %m%n</pattern>
</encoder>
</appender>
<appender name="pandaAppender" class="ch.qos.logback.core.ConsoleAppender">
<Target>System.out</Target>
<encoder>
<pattern>L:%p %m%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="stdout"/>
</root>
<logger name="com.happypanda" level="INFO" additivity="false">
<appender-ref ref="stdout"/>
</logger>
<logger name="com.happypanda.myproject" level="INFO" additivity="false">
<appender-ref ref="pandaAppender"/>
</logger>
<logger name="com.happypanda.libB" level="INFO" additivity="false">
<appender-ref ref="pandaAppender"/>
</logger>
<logger name="org.apache.http" level="ERROR">
<appender-ref ref="stdout"/>
</logger>
<logger name="org.apache.http.wire" level="ERROR">
<appender-ref ref="stdout"/>
</logger>
</configuration>
Later later edit:
I've tried to simplify the logic: to remove the libA and use directly libB in project.
Now the log level in libB is debug + there are additional logs from httpclient (see this as reference Disable HttpClient logging)
Later later edit:
In my application I'm taking the logback.xml from external source (is not in resources). In a static block I have the following config:
System.setProperty("logging.config", "file:/services/config/logback.xml");
For testing purposes I've moved the config log inside the resources file of the project. Now all the logs in both project and libB are ok.
I've tried to set them as command line properties but doing so I see debug logs in libB.
CMD java -XX:MinRAMPercentage=40.0 -XX:MaxRAMPercentage=80.0 -XX:+HeapDumpOnOutOfMemoryError -Dlogging.config=/services/config/logback.xml -jar