Asma Zinneera Jabir
2017-07-05 08:30:22 UTC
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
<https://github.com/apache/commons-logging/blob/LOGGING_1_2/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java#L843>)
from a list (L162
<https://github.com/apache/commons-logging/blob/LOGGING_1_2/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java#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
package?
stackoverflow question: Apache commons-logging bridge for log4j2
<https://stackoverflow.com/questions/44839779/apache-commons-logging-bridge-for-log4j2>
*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
<https://github.com/apache/commons-logging/blob/LOGGING_1_2/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java#L843>)
from a list (L162
<https://github.com/apache/commons-logging/blob/LOGGING_1_2/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java#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
package?
stackoverflow question: Apache commons-logging bridge for log4j2
<https://stackoverflow.com/questions/44839779/apache-commons-logging-bridge-for-log4j2>