Slackbot
05/30/2023, 9:46 AMVampire
05/30/2023, 9:53 AM--scan
?
It contains pretty good information about the dependencies and where they come from.
If not, maybe the dependencyInsight
task can help you.Vampire
05/30/2023, 9:54 AMVampire
05/30/2023, 9:54 AMVampire
05/30/2023, 9:55 AMVampire
05/30/2023, 9:56 AMVampire
05/30/2023, 9:57 AMcommons-logging
is just a logging API, so usually you should not need to exclude it, but to provide the proper bridging artifact that forwards the commons-logging
logged messages to your chosen logging implementation like log4j-core
.Hantsy Bai
05/30/2023, 10:23 AMlog.debug
etc, does not print message as expected. Our project is a spring boot project, by default it includes logback-classic as logging framework. So I tried to remove other logging libs in the project.Hantsy Bai
05/30/2023, 10:27 AMHantsy Bai
05/30/2023, 10:28 AMVampire
05/30/2023, 10:28 AMcommons-logging
are just log facades that require that you put the proper bridging library onto the runtime classpath.
So if you use logback-classic
as logging framework, you need to put the according slf4j
bridges for the log facades your dependencies use.
So for commons-logging
you would need org.slf4j:jcl-over-slf4j
on the runtime classpath, for java.util.logging
, org.slf4j:jul-to-slf4j
, for log4j org.slf4j:log4j-over-slf4j
and so on.
Some bridges like the one for JUL might require additional actions, for example to set a system property before any logging call is done and enabling also the intended log level or all levels for that and so on.Vampire
05/30/2023, 10:41 AMI found it is also required by dataframe plugin.That's in the build logic. Gradle should care about providing the bridging libraries to capture those log files. That has nothing to do with your production classpath.
Hantsy Bai
05/30/2023, 10:50 AMjcl-over-slf4j
. I have just added this explicitly, but the log in our project still does not work, no any output message from our log.debug in the console.Hantsy Bai
05/30/2023, 10:52 AM+--- org.springframework.boot:spring-boot-starter-logging:3.1.0
| | | +--- ch.qos.logback:logback-classic:1.4.7
| | | | +--- ch.qos.logback:logback-core:1.4.7
| | | | \--- org.slf4j:slf4j-api:2.0.4 -> 2.0.7
| | | +--- org.apache.logging.log4j:log4j-to-slf4j:2.20.0
| | | | +--- org.apache.logging.log4j:log4j-api:2.20.0
| | | | \--- org.slf4j:slf4j-api:1.7.36 -> 2.0.7
| | | \--- org.slf4j:jul-to-slf4j:2.0.7
| | | \--- org.slf4j:slf4j-api:2.0.7
Hantsy Bai
05/30/2023, 10:53 AMcommons-logging
API and also can bridge other logging to this impl since spring 5.x.Vampire
05/30/2023, 11:00 AMfrom our log.debugWell, what logging library do you use there? If it is not
commons-logging
then the discussion about how to get the commons-logging
logs is moot for your concrete problem, even though valid in general.
What type is log
?Hantsy Bai
05/30/2023, 12:48 PMprivate val log = LoggerFactory.getLogger(XXX::class.java)
Hantsy Bai
05/30/2023, 12:51 PMVampire
05/30/2023, 12:57 PMlogback-classic
should get the log messages.
Unless there is maybe also some other slf4j implementation, but then it should usually also complain that there are multiple on the classpath.
Your build scan shows that there is just slf4j-api
, jul-to-slf4j
, log4j-to-slf4j
, and logback-classic
on the runtime classpath. So if you log using slf4j, the messages should come through properly if your logback configuration enables the messages. The JCL messages will still be lost unless you add the according bridge library, but that should not affect your slf4j log calls.