logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Asma Zinneera Jabir <azinne...@gmail.com>
Subject Apache commons-logging bridge for log4j2
Date Wed, 05 Jul 2017 08:30:22 GMT
I am trying to set up log4j2 for Apache Commons Logging using the
*commons-logging.properties* file in an OSGi environment. For Log4j 1 I
could use org.apache.commons.logging.Log=org.apache.commons.logging.impl.
Log4JLogger which maps to version Log4j 1.2. I couldn't find out the
implementation for log4J2. The version I am using is 2.8.2.

There is a central logging component which is referred by other components
and this component bundles other needed loggers (e.g. commons-logging,
log4j/log4j2) added as dependencies.

The Log4J2 documentation for Log4J Commons Logging Bridge
<https://logging.apache.org/log4j/log4j-2.3/log4j-jcl/index.html> specifies
that by just *adding the bridge jar along with the other Log4j 2 jars and
the Commons Logging jar, all logging done using the Commons Logging API
will be routed to Log4*. I tried this by adding

   - log4j-api
   - log4j-core
   - log4j-jcl
   - commons-logging

dependencies in the *pom.xml* of the central logging component and bundled
with it without (and with just to check) using the
*commons-logging.properties* but didn't work that way. How can I implement
this with or without the commons-logging.properties?

I debugged the commons-logging source code and found in LogFactoryImpl.java it
looks for a logging implementation (L843
from a list (L162
Here since the Log4JLogger does not support Log4J2 it then sets to the next
in line, that is JDK14Logger. Since the Log4J2 documentaiton says adding
the bridge simply maps the logs from JCL to Log4J2, what role does the
bridging api play here? I noticed the LogFactoryImpl.java and Log4JLog.java in
it but how does commons-logging refer to these which are in a different

stackoverflow question: Apache commons-logging bridge for log4j2

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message