3

We're using Log4j (via Slf4j) for logging.

Our log4j configuration is rather simple:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
  <Appenders>
    <Console name="Console">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Root level="INFO">
      <AppenderRef ref="Console"/>
    </Root>
    <Logger name="net.sf.jsi.rtree.RTree" level="INFO">
      <AppenderRef ref="Console"/>
    </Logger>
  </Loggers>
</Configuration>

Note that root logger is set to INFO.

However, we're getting a huge amount of DEBUG logs from a third-party library (net.sf.jsi). Logs we're absolutely not interested in. My guess is that there's a different Log4j configuration on the classpath somewhere which gets picked up and sets root logger to DEBUG.

My question is, how could I found which configuration is actually loaded and used by log4j?

Update:

I have seen this "possible duplicate". However, the answer which suggests to use -Dlog4j.debug does not work for me.
I've added -Dlog4j.debug to the VM arguments. I only get:

DEBUG StatusLogger org.slf4j.helpers.Log4jLoggerFactory is not on classpath. Good!
DEBUG StatusLogger Using ShutdownCallbackRegistry class org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
WARN StatusLogger Multiple logging implementations found: 
Factory: org.apache.logging.log4j.core.impl.Log4jContextFactory, Weighting: 10
Factory: org.apache.logging.slf4j.SLF4JLoggerContextFactory, Weighting: 15
Using factory: org.apache.logging.slf4j.SLF4JLoggerContextFactory

which is not enough info for me.

lexicore
  • 42,748
  • 17
  • 132
  • 221
  • 1
    Have you tried to set the level of this third party library packages to - say ERROR - in your own config? I guess you're not using Spring since not mentioned. – pirho Jul 14 '20 at 17:46
  • @pirho My config sets root logger level to `INFO`. I thought this should apply to the logger of the third party lib as well. – lexicore Jul 14 '20 at 18:31
  • 1
    Yes but maybe the 3rd party library sets log level to DEBUG not by ROOT logger but by some own logger by package name or so. Just wondering if it would be the case. In that case it might not matter what you set in your ROOT because there is non root logger for those DEBUG rows. – pirho Jul 14 '20 at 19:06
  • @pirho I've added a `Logger` configuration for the third-party library. Unfortunately, that did not help. I'm still getting debug logs for the logger I've configured to `INFO`. – lexicore Jul 15 '20 at 08:47

0 Answers0