sdeboy 2004/12/19 23:28:07
Modified: src/java/org/apache/log4j LogManager.java
Log:
Added a no-arg getLogger method that returns a Logger using the caller's
class name (relies on the new LocationInfo classes).
Suggested by Kevin Burton
Revision Changes Path
1.28 +10 -0 logging-log4j/src/java/org/apache/log4j/LogManager.java
Index: LogManager.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/LogManager.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- LogManager.java 1 Dec 2004 08:37:55 -0000 1.27
+++ LogManager.java 20 Dec 2004 07:28:07 -0000 1.28
@@ -27,6 +27,7 @@
import org.apache.log4j.spi.LoggerRepository;
import org.apache.log4j.spi.RepositorySelector;
import org.apache.log4j.spi.RootLogger;
+import org.apache.log4j.spi.location.LocationInfo;
import java.util.Enumeration;
@@ -177,6 +178,15 @@
return repositorySelector.getLoggerRepository().getRootLogger();
}
+ /**
+ * Retrieve a [EMAIL PROTECTED] Logger} instance based on the calling
class name.
+ *
+ */
+ public static Logger getLogger() {
+ LocationInfo info = new LocationInfo(new Exception(),
LogManager.class.getName());
+ return getLogger(info.getClassName());
+ }
+
/**
Retrieve the appropriate [EMAIL PROTECTED] Logger} instance.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]