Use a class' canonical name instead of name to create its
logger name. Add tests.
@@ -18,6 +18,7 @@ package org.apache.logging.log4j;
import org.apache.logging.log4j.message.ParameterizedMessageFactory;
import org.apache.logging.log4j.spi.LoggerContext;
+import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -27,6 +28,14 @@ import static org.junit.Assert.*;
*/
public class LogManagerTest {
+ static class InnerClass {
+ final static Logger LOGGER = LogManager.getLogger(InnerClass.class);
+ }
+
+ static class StaticInnerClass {
+ final static Logger LOGGER = LogManager.getLogger(StaticInnerClass.class);
+ }
+
@Test
public void testGetLogger() {
Logger logger = LogManager.getLogger();
@@ -55,9 +64,18 @@ public class LogManagerTest {
assertTrue("Incorrect Logger name: " + logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
}
+ @Test
+ public void testGetLoggerForInnerClass() {
+ Assert.assertEquals("org.apache.logging.log4j.LogManagerTest.InnerClass", InnerClass.LOGGER.getName());
+ }
+
+ @Test
+ public void testGetLoggerForStaticInnerClass() {
+ Assert.assertEquals("org.apache.logging.log4j.LogManagerTest.StaticInnerClass", StaticInnerClass.LOGGER.getName());
+ }
+
@Test
public void testShutdown() {
final LoggerContext loggerContext = LogManager.getContext(false);
- LogManager.shutdown(loggerContext);
}
}
