LogManager { public static Logger getLogger(final String name) { synchronized (mutex) { return getOrCreateLogger(name); } } LogManager(); static Logger getRootLogger(); static Logger getLogger(final String name); static Logger getLogger(final String name, final LoggerFactory factory); @SuppressWarnings("rawtypes") static Logger getLogger(final Class clazz); static Logger exists(final String name); @SuppressWarnings("rawtypes") static Enumeration getCurrentLoggers(); static void shutdown(); static void resetConfiguration();  }
@Test public void loggerByName() { Logger logger = LogManager.getLogger("test.example.MyClass"); assertThat(logger.getName()).isEqualTo("test.example.MyClass"); Category parent = logger.getParent(); assertThat(parent).isNotNull(); assertThat(parent.getName()).isEqualTo("test.example"); }
@Test public void loggerByNameAndFactory() { Logger logger = LogManager.getLogger("test.example.MyClass", mock(LoggerFactory.class)); assertThat(logger).isSameAs(logger); }
@Test public void loggerByClass() { Logger logger = LogManager.getLogger(LogManagerTest.class); assertThat(logger.getName()).isEqualTo(LogManagerTest.class.getName()); Category parent = logger.getParent(); assertThat(parent).isNotNull(); assertThat(parent.getName()).isEqualTo(LogManagerTest.class.getPackageName()); }