diff --git a/openjpa-lib/pom.xml b/openjpa-lib/pom.xml
index 4b9535706..3d6e85a30 100644
--- a/openjpa-lib/pom.xml
+++ b/openjpa-lib/pom.xml
@@ -56,6 +56,11 @@
log4j-core
provided
+
+ org.apache.logging.log4j
+ log4j-1.2-api
+ provided
+
org.slf4j
slf4j-api
diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
index d7d54c345..56b978b33 100644
--- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
+++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
@@ -157,6 +157,7 @@ public class ConfigurationImpl
"openjpa", LogFactoryImpl.class.getName(),
"commons", "org.apache.openjpa.lib.log.CommonsLogFactory",
"log4j", "org.apache.openjpa.lib.log.Log4JLogFactory",
+ "log4j2", "org.apache.openjpa.lib.log.Log4J2LogFactory",
"slf4j", "org.apache.openjpa.lib.log.SLF4JLogFactory",
"jul", "org.apache.openjpa.lib.log.JULLogFactory",
"none", NoneLogFactory.class.getName(),
diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4J2LogFactory.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4J2LogFactory.java
new file mode 100644
index 000000000..72aa0698d
--- /dev/null
+++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4J2LogFactory.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.lib.log;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ * {@link LogFactory} implementation that delegates to the Log4J-2.x framework.
+ * It's configuration key is {@code openjpa.Log=log4j2}.
+ *
+ */
+public class Log4J2LogFactory extends LogFactoryAdapter {
+
+ @Override
+ protected Log newLogAdapter(String channel) {
+ return new LogAdapter(LogManager.getLogger(channel));
+ }
+
+ /**
+ * Adapts a Log4J2 logger to the {@link Log}
+ * interface.
+ */
+ public static class LogAdapter implements Log {
+
+ private Logger _log;
+
+ private LogAdapter(Logger wrapee) {
+ _log = wrapee;
+ }
+
+ public Logger getDelegate() {
+ return _log;
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return _log.isTraceEnabled();
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return _log.isInfoEnabled();
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return _log.isWarnEnabled();
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return _log.isErrorEnabled();
+ }
+
+ @Override
+ public boolean isFatalEnabled() {
+ return _log.isFatalEnabled();
+ }
+
+ @Override
+ public void trace(Object o) {
+ _log.debug(o);
+ }
+
+ @Override
+ public void trace(Object o, Throwable t) {
+ _log.debug(o, t);
+ }
+
+ @Override
+ public void info(Object o) {
+ _log.info(o);
+ }
+
+ @Override
+ public void info(Object o, Throwable t) {
+ _log.info(o, t);
+ }
+
+ @Override
+ public void warn(Object o) {
+ _log.warn(o);
+ }
+
+ @Override
+ public void warn(Object o, Throwable t) {
+ _log.warn(o, t);
+ }
+
+ @Override
+ public void error(Object o) {
+ _log.error(o);
+ }
+
+ @Override
+ public void error(Object o, Throwable t) {
+ _log.error(o, t);
+ }
+
+ @Override
+ public void fatal(Object o) {
+ _log.fatal(o);
+ }
+
+ @Override
+ public void fatal(Object o, Throwable t) {
+ _log.fatal(o, t);
+ }
+ }
+}
diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java
index dd2651c72..4bf377c44 100644
--- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java
+++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java
@@ -18,11 +18,12 @@
*/
package org.apache.openjpa.lib.log;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
/**
- * {@link LogFactory} implementation that delegates to the Log4J framework.
+ * {@link LogFactory} implementation that delegates to the Log4J 1.x framework.
*
* @author Patrick Linskey
*/
@@ -30,7 +31,7 @@ public class Log4JLogFactory extends LogFactoryAdapter {
@Override
protected Log newLogAdapter(String channel) {
- return new LogAdapter(LogManager.getLogger(channel));
+ return new LogAdapter((Logger) LogManager.getLogger(channel));
}
/**
@@ -51,27 +52,27 @@ public class Log4JLogFactory extends LogFactoryAdapter {
@Override
public boolean isTraceEnabled() {
- return _log.isTraceEnabled();
+ return _log.isEnabledFor(Level.DEBUG);
}
@Override
public boolean isInfoEnabled() {
- return _log.isInfoEnabled();
+ return _log.isEnabledFor(Level.INFO);
}
@Override
public boolean isWarnEnabled() {
- return _log.isWarnEnabled();
+ return _log.isEnabledFor(Level.WARN);
}
@Override
public boolean isErrorEnabled() {
- return _log.isErrorEnabled();
+ return _log.isEnabledFor(Level.ERROR);
}
@Override
public boolean isFatalEnabled() {
- return _log.isFatalEnabled();
+ return _log.isEnabledFor(Level.FATAL);
}
@Override
diff --git a/pom.xml b/pom.xml
index cf6c2234a..a03c6590f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -96,6 +96,8 @@
4.18
1.1.2
+ 2.14.0
+
2.9.0
-SUBMODULES-NEED-TO-OVERRIDE-THIS-
@@ -1782,8 +1784,15 @@
org.apache.logging.log4j
log4j-core
- 2.11.1
+ ${log4j2.version}
+
+
+ org.apache.logging.log4j
+ log4j-1.2-api
+ ${log4j2.version}
+
+
io.fabric8
kubernetes-client