1
0

[LOGGING-132] Jdk14Logger now correctly uses the specified logger name.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/logging/trunk@1448063 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart
2013-02-20 10:01:41 +00:00
parent 310645a75a
commit fa3c76104f
3 changed files with 11 additions and 8 deletions

View File

@@ -44,6 +44,9 @@ The <action> type attribute can be add,update,fix,remove.
</properties>
<body>
<release version="1.1.2" date="In SVN" description="Bug fixes.">
<action type="fix" issue="LOGGING-132">
Jdk14Logger now correctly uses the specified logger name.
</action>
<action type="update" issue="LOGGING-133">
Change scope of Jdk14Logger.log(Level, String, Throwable) to protected, allowing
subclasses to modify the logging output.

View File

@@ -75,13 +75,13 @@ public class Jdk14Logger implements Log, Serializable {
// Hack (?) to get the stack trace.
Throwable dummyException = new Throwable();
StackTraceElement locations[] = dummyException.getStackTrace();
// Caller will be the third element
String cname = "unknown";
// LOGGING-132: use the provided logger name instead of the class name
String cname = name;
String method = "unknown";
// Caller will be the third element
if( locations != null && locations.length > 2 ) {
StackTraceElement caller=locations[2];
cname=caller.getClassName();
method=caller.getMethodName();
StackTraceElement caller = locations[2];
method = caller.getMethodName();
}
if( ex == null ) {
logger.logp( level, cname, method, msg );

View File

@@ -168,10 +168,10 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
public void setUp() throws Exception {
setUpManager
("org/apache/commons/logging/jdk14/CustomConfig.properties");
setUpLogger("TestLogger");
setUpLogger(this.getClass().getName());
setUpHandlers();
setUpFactory();
setUpLog("TestLogger");
setUpLog(this.getClass().getName());
}
@@ -244,7 +244,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
public void testPristineLogger() {
assertNotNull("Logger exists", logger);
assertEquals("Logger name", "TestLogger", logger.getName());
assertEquals("Logger name", this.getClass().getName(), logger.getName());
// Assert which logging levels have been enabled
assertTrue(logger.isLoggable(Level.SEVERE));