logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1377000 - in /logging/log4j/log4j2/trunk: api/src/main/java/org/apache/logging/log4j/LogManager.java api/src/test/java/org/apache/logging/log4j/LoggerTest.java src/changes/changes.xml
Date Fri, 24 Aug 2012 17:29:07 GMT
Author: rgoers
Date: Fri Aug 24 17:29:06 2012
New Revision: 1377000

URL: http://svn.apache.org/viewvc?rev=1377000&view=rev
Log:
Fix LOG4J2-70 - Add getLogger(Class) to LogManager

Modified:
    logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/LogManager.java
    logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/LoggerTest.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/LogManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/LogManager.java?rev=1377000&r1=1376999&r2=1377000&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/LogManager.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/LogManager.java
Fri Aug 24 17:29:06 2012
@@ -130,6 +130,15 @@ public class LogManager {
     }
 
     /**
+     * Return a Logger using the fully qualified name of the Class as the Logger name.
+     * @param clazz The Class whose name should be used as the Logger name.
+     * @return The Logger.
+     */
+    public static Logger getLogger(Class clazz) {
+        return factory.getContext(LogManager.class.getName(), false).getLogger(clazz.getName());
+    }
+
+    /**
      * Return a Logger with the specified name.
      *
      * @param fqcn The fully qualified class name of the class that this method is a member
of.

Modified: logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/LoggerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/LoggerTest.java?rev=1377000&r1=1376999&r2=1377000&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/LoggerTest.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/LoggerTest.java
Fri Aug 24 17:29:06 2012
@@ -24,6 +24,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Locale;
 
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
 
@@ -128,4 +129,10 @@ public class LoggerTest {
         assertTrue("Incorrect structured data: " + results.get(0),results.get(0).startsWith(
             " INFO Transfer [Audit@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"]
Transfer Complete"));
     }
+
+    @Test
+    public void LoggerByClass() {
+        Logger classLogger = LogManager.getLogger(LoggerTest.class);
+        assertNotNull(classLogger);
+    }
 }

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1377000&r1=1376999&r2=1377000&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Fri Aug 24 17:29:06 2012
@@ -23,6 +23,9 @@
 
   <body>
     <release version="2.0-alpha2" date="2012-08-24" description="Bug fixes and minor enhancements">
+      <action issue="LOG4J2-70" dev="rgoers" type="add">
+        Add getLogger(Class) to LogManager.
+      </action>
       <action issue="LOG4J2-69" dev="rgoers" type="add">
         Allow Flume agents to be embedded into the Flume Appender.
       </action>



Mime
View raw message