From d6e99751bcd53f9c2789ff115844e520d788c42d Mon Sep 17 00:00:00 2001 From: John Vasileff Date: Sun, 18 Sep 2011 19:30:05 -0400 Subject: [PATCH 1/4] add test for Category when using a log4j2 Logger --- .../test/java/org/apache/log4j/CategoryTest.java | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/log4j12-api/src/test/java/org/apache/log4j/CategoryTest.java b/log4j12-api/src/test/java/org/apache/log4j/CategoryTest.java index 9d4c699..4eecca8 100644 --- a/log4j12-api/src/test/java/org/apache/log4j/CategoryTest.java +++ b/log4j12-api/src/test/java/org/apache/log4j/CategoryTest.java @@ -17,6 +17,7 @@ package org.apache.log4j; +import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.core.Layout; import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.appender.ListAppender; @@ -110,6 +111,23 @@ public class CategoryTest { } /** + * Test using a pre-existing log4j2 logger + */ + @Test + public void testExistingLog4j2Logger() { + // create the logger using LogManager + LogManager.getLogger("existingLogger"); + // Logger will be the one created above + Logger logger = Logger.getLogger("existingLogger"); + logger.setLevel(Level.ERROR); + Priority debug = Level.DEBUG; + // the next line will throw an exception if the LogManager loggers + // aren't supported by 1.2 Logger/Category + logger.l7dlog(debug, "Hello, World", new Object[0], null); + assertTrue(appender.getEvents().size() == 0); + } + + /** * Tests setPriority(Priority). * * @deprecated -- 1.7.6