You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2014/11/06 20:28:59 UTC
logging-log4j2 git commit: [LOG4J2-892] JUL adapter does not map
Log4j'2 FATAL level to JUL level.
Repository: logging-log4j2
Updated Branches:
refs/heads/master 62519d838 -> f9b0bbeed
[LOG4J2-892] JUL adapter does not map Log4j'2 FATAL level to JUL level.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f9b0bbee
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f9b0bbee
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f9b0bbee
Branch: refs/heads/master
Commit: f9b0bbeed839f447fc0602fdee5a009315ebfcbb
Parents: 62519d8
Author: Gary Gregory <ga...@gmail.com>
Authored: Thu Nov 6 14:28:52 2014 -0500
Committer: Gary Gregory <ga...@gmail.com>
Committed: Thu Nov 6 14:28:52 2014 -0500
----------------------------------------------------------------------
.../log4j/jul/DefaultLevelConverter.java | 3 +-
.../log4j/jul/JavaLevelTranslatorTest.java | 73 ++++++++++++++++++++
.../logging/log4j/jul/LevelTranslatorTest.java | 69 ------------------
.../log4j/jul/Log4jLevelTranslatorTest.java | 67 ++++++++++++++++++
src/changes/changes.xml | 3 +
5 files changed, 145 insertions(+), 70 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f9b0bbee/log4j-jul/src/main/java/org/apache/logging/log4j/jul/DefaultLevelConverter.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/DefaultLevelConverter.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/DefaultLevelConverter.java
index 01d5aa3..b79478b 100644
--- a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/DefaultLevelConverter.java
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/DefaultLevelConverter.java
@@ -32,7 +32,7 @@ public class DefaultLevelConverter implements LevelConverter {
private final Map<java.util.logging.Level, Level> JDK_TO_LOG4J =
new IdentityHashMap<java.util.logging.Level, Level>(9);
private final Map<Level, java.util.logging.Level> LOG4J_TO_JDK =
- new IdentityHashMap<Level, java.util.logging.Level>(9);
+ new IdentityHashMap<Level, java.util.logging.Level>(10);
public DefaultLevelConverter() {
JDK_TO_LOG4J.put(java.util.logging.Level.OFF, Level.OFF);
@@ -52,6 +52,7 @@ public class DefaultLevelConverter implements LevelConverter {
LOG4J_TO_JDK.put(Level.INFO, java.util.logging.Level.INFO);
LOG4J_TO_JDK.put(Level.WARN, java.util.logging.Level.WARNING);
LOG4J_TO_JDK.put(Level.ERROR, java.util.logging.Level.SEVERE);
+ LOG4J_TO_JDK.put(Level.FATAL, java.util.logging.Level.SEVERE);
LOG4J_TO_JDK.put(Level.ALL, java.util.logging.Level.ALL);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f9b0bbee/log4j-jul/src/test/java/org/apache/logging/log4j/jul/JavaLevelTranslatorTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/JavaLevelTranslatorTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/JavaLevelTranslatorTest.java
new file mode 100644
index 0000000..b912257
--- /dev/null
+++ b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/JavaLevelTranslatorTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.logging.log4j.jul;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests that all JUL levels are mapped to a Log4j level.
+ */
+@RunWith(Parameterized.class)
+public class JavaLevelTranslatorTest {
+
+ private final java.util.logging.Level javaLevel;
+ private final Level log4jLevel;
+
+ public JavaLevelTranslatorTest(final java.util.logging.Level javaLevel, final Level log4jLevel) {
+ this.javaLevel = javaLevel;
+ this.log4jLevel = log4jLevel;
+ }
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] {
+ // All 9 JUL levels, All 8 Log4j levels and extras
+ // @formatter:off
+ {java.util.logging.Level.OFF, Level.OFF},
+ {java.util.logging.Level.SEVERE, Level.ERROR},
+ {java.util.logging.Level.WARNING, Level.WARN},
+ {java.util.logging.Level.INFO, Level.INFO},
+ {java.util.logging.Level.CONFIG, LevelTranslator.CONFIG},
+ {java.util.logging.Level.FINE, Level.DEBUG},
+ {java.util.logging.Level.FINER, Level.TRACE},
+ {java.util.logging.Level.FINEST, LevelTranslator.FINEST},
+ {java.util.logging.Level.ALL, Level.ALL}
+ // @formatter:on
+ });
+ }
+
+ @Test
+ public void testToLevel() throws Exception {
+ final Level actualLevel = LevelTranslator.toLevel(javaLevel);
+ assertEquals(log4jLevel, actualLevel);
+ }
+
+ @Test
+ public void testToJavaLevel() throws Exception {
+ final java.util.logging.Level actualLevel = LevelTranslator.toJavaLevel(log4jLevel);
+ assertEquals(javaLevel, actualLevel);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f9b0bbee/log4j-jul/src/test/java/org/apache/logging/log4j/jul/LevelTranslatorTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/LevelTranslatorTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/LevelTranslatorTest.java
deleted file mode 100644
index 7ef8714..0000000
--- a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/LevelTranslatorTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.logging.log4j.jul;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.apache.logging.log4j.Level;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import static org.junit.Assert.*;
-
-@RunWith(Parameterized.class)
-public class LevelTranslatorTest {
-
- private final java.util.logging.Level javaLevel;
- private final Level log4jLevel;
-
- public LevelTranslatorTest(final java.util.logging.Level javaLevel, final Level log4jLevel) {
- this.javaLevel = javaLevel;
- this.log4jLevel = log4jLevel;
- }
-
- @Parameterized.Parameters
- public static Collection<Object[]> data() {
- return Arrays.asList(
- new Object[][]{
- {java.util.logging.Level.OFF, Level.OFF},
- {java.util.logging.Level.ALL, Level.ALL},
- {java.util.logging.Level.SEVERE, Level.ERROR},
- {java.util.logging.Level.WARNING, Level.WARN},
- {java.util.logging.Level.INFO, Level.INFO},
- {java.util.logging.Level.CONFIG, LevelTranslator.CONFIG},
- {java.util.logging.Level.FINE, Level.DEBUG},
- {java.util.logging.Level.FINER, Level.TRACE},
- {java.util.logging.Level.FINEST, LevelTranslator.FINEST}
- }
- );
- }
-
- @Test
- public void testToLevel() throws Exception {
- final Level actualLevel = LevelTranslator.toLevel(javaLevel);
- assertEquals(log4jLevel, actualLevel);
- }
-
- @Test
- public void testToJavaLevel() throws Exception {
- final java.util.logging.Level actualLevel = LevelTranslator.toJavaLevel(log4jLevel);
- assertEquals(javaLevel, actualLevel);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f9b0bbee/log4j-jul/src/test/java/org/apache/logging/log4j/jul/Log4jLevelTranslatorTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/Log4jLevelTranslatorTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/Log4jLevelTranslatorTest.java
new file mode 100644
index 0000000..e38159a
--- /dev/null
+++ b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/Log4jLevelTranslatorTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.logging.log4j.jul;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/**
+ * Tests that all Log4j levels are mapped to a JUL level.
+ */
+@RunWith(Parameterized.class)
+public class Log4jLevelTranslatorTest {
+
+ private final java.util.logging.Level javaLevel;
+ private final Level log4jLevel;
+
+ public Log4jLevelTranslatorTest(final java.util.logging.Level javaLevel, final Level log4jLevel) {
+ this.javaLevel = javaLevel;
+ this.log4jLevel = log4jLevel;
+ }
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] {
+ // Some JUL levels, All 8 Log4j levels
+ // @formatter:off
+ {java.util.logging.Level.OFF, Level.OFF},
+ {java.util.logging.Level.SEVERE, Level.FATAL},
+ {java.util.logging.Level.SEVERE, Level.ERROR},
+ {java.util.logging.Level.WARNING, Level.WARN},
+ {java.util.logging.Level.INFO, Level.INFO},
+ {java.util.logging.Level.FINE, Level.DEBUG},
+ {java.util.logging.Level.FINER, Level.TRACE},
+ {java.util.logging.Level.ALL, Level.ALL},
+ // @formatter:on
+ });
+ }
+
+ @Test
+ public void testToJavaLevel() throws Exception {
+ final java.util.logging.Level actualLevel = LevelTranslator.toJavaLevel(log4jLevel);
+ assertEquals(javaLevel, actualLevel);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f9b0bbee/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 45a6b6d..3518beb 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,9 @@
</properties>
<body>
<release version="2.1.1" date="201?-??-??" description="GA Release 2.1.1">
+ <action issue="LOG4J2-892" dev="ggregory" type="fix">
+ JUL adapter does not map Log4j'2 FATAL level to JUL level.
+ </action>
<action issue="LOG4J2-881" dev="ggregory" type="fix" due-to="Mariano Gonzalez">
AbstractLifecycle should not implement equals() and hashCode().
</action>