[LOG4J2-2023] Use a class' canonical name instead of name to create its
logger name.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b78cb767
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b78cb767
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b78cb767

Branch: refs/heads/LOG4J2-1431
Commit: b78cb76737b7ec42abd9b2330243aa6d58bb9cb3
Parents: 1bd65c7
Author: Gary Gregory <[email protected]>
Authored: Mon Aug 21 09:11:39 2017 -0600
Committer: Gary Gregory <[email protected]>
Committed: Mon Aug 21 09:11:39 2017 -0600

----------------------------------------------------------------------
 .../main/java/org/apache/logging/log4j/LogManager.java    |  4 ++--
 .../log4j/core/impl/NestedLoggingFromToStringTest.java    | 10 +++++-----
 src/changes/changes.xml                                   |  3 +++
 3 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b78cb767/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java 
b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
index fde71aa..a59b1be 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
@@ -548,7 +548,7 @@ public class LogManager {
      */
     public static Logger getLogger(final Class<?> clazz) {
         final Class<?> cls = callerClass(clazz);
-        return getContext(cls.getClassLoader(), 
false).getLogger(cls.getName());
+        return getContext(cls.getClassLoader(), 
false).getLogger(cls.getCanonicalName());
     }
 
     /**
@@ -564,7 +564,7 @@ public class LogManager {
      */
     public static Logger getLogger(final Class<?> clazz, final MessageFactory 
messageFactory) {
         final Class<?> cls = callerClass(clazz);
-        return getContext(cls.getClassLoader(), 
false).getLogger(cls.getName(), messageFactory);
+        return getContext(cls.getClassLoader(), 
false).getLogger(cls.getCanonicalName(), messageFactory);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b78cb767/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromToStringTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromToStringTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromToStringTest.java
index c5c037c..d0c35cb 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromToStringTest.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromToStringTest.java
@@ -102,7 +102,7 @@ public class NestedLoggingFromToStringTest {
         logger.info("main: argCount={} it={}", "2", it);
         final List<String> list = listAppender.getMessages();
 
-        final String expect1 = "DEBUG 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest$ParameterizedLoggingThing
 getX: values x=3 y=4 z=5";
+        final String expect1 = "DEBUG 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest.ParameterizedLoggingThing
 getX: values x=3 y=4 z=5";
         final String expect2 = "INFO 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest main: 
argCount=2 it=[ParameterizedLoggingThing x=3 y=4 z=5]";
         assertEquals(expect1, list.get(0));
         assertEquals(expect2, list.get(1));
@@ -114,7 +114,7 @@ public class NestedLoggingFromToStringTest {
         logger.info("next: it={} some{} other{}", it, "AA", "BB");
         final List<String> list = listAppender.getMessages();
 
-        final String expect1 = "DEBUG 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest$ParameterizedLoggingThing
 getX: values x=3 y=4 z=5";
+        final String expect1 = "DEBUG 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest.ParameterizedLoggingThing
 getX: values x=3 y=4 z=5";
         final String expect2 = "INFO 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest next: 
it=[ParameterizedLoggingThing x=3 y=4 z=5] someAA otherBB";
         assertEquals(expect1, list.get(0));
         assertEquals(expect2, list.get(1));
@@ -125,9 +125,9 @@ public class NestedLoggingFromToStringTest {
         logger.info(new ObjectLoggingThing1());
         final List<String> list = listAppender.getMessages();
 
-        final String expect1 = "DEBUG 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest$ParameterizedLoggingThing
 getX: values x=3 y=4 z=5";
-        final String expect2 = "TRACE 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest$ObjectLoggingThing2
 [ParameterizedLoggingThing x=3 y=4 z=5]";
-        final String expect3 = "TRACE 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest$ObjectLoggingThing1
 [ObjectLoggingThing2 x=123]";
+        final String expect1 = "DEBUG 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest.ParameterizedLoggingThing
 getX: values x=3 y=4 z=5";
+        final String expect2 = "TRACE 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest.ObjectLoggingThing2
 [ParameterizedLoggingThing x=3 y=4 z=5]";
+        final String expect3 = "TRACE 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest.ObjectLoggingThing1
 [ObjectLoggingThing2 x=123]";
         final String expect4 = "INFO 
org.apache.logging.log4j.core.impl.NestedLoggingFromToStringTest 
[ObjectLoggingThing1 y=999]";
         assertEquals(expect1, list.get(0));
         assertEquals(expect2, list.get(1));

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b78cb767/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 12033e4..130a4c6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -43,6 +43,9 @@
       <action issue="LOG4J2-2013" dev="ggregory" type="fix" due-to="Taylor 
Patton, Gary Gregory">
         SslSocketManager does not apply SSLContext on TCP reconnect.
       </action>
+      <action issue="LOG4J2-2023" dev="ggregory" type="update">
+        Use a class' canonical name instead of name to create its logger name.
+      </action>
       <action issue="LOG4J2-2015" dev="ggregory" type="update">
         Allow KeyStoreConfiguration and TrustStoreConfiguration to find files 
as resources.
       </action>

Reply via email to