Bug 1079106 - Log4j Logger.getParent() inconsistent
Summary: Log4j Logger.getParent() inconsistent
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Logging
Version: 6.2.2
Hardware: Unspecified
OS: Unspecified
unspecified
urgent
Target Milestone: DR4
: EAP 6.4.0
Assignee: James Perkins
QA Contact: Nikoleta Hlavickova
URL:
Whiteboard:
Depends On: 1148632
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-03-21 01:52 UTC by James Livingston
Modified: 2019-08-19 12:41 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker LOGMGR-95 0 Major Resolved Log4j Logger.getParent() inconsistent 2016-03-22 19:19:42 UTC

Description James Livingston 2014-03-21 01:52:27 UTC
Log4j Loggers have a getParent() method, whose return value is set up by JBossLogManagerFacade.updateParents(). The method locates the closest parent node which has an existing Log4J logger created at the time. This results in the parent being different depending on the order Log4j loggers are used in.

Consider:
Logger.getLogger("a");
Logger.getLogger("a.b.c");
Logger.getLogger("a.b");

When the second line causes updateParents() to be called, LoggerNode.getOrCreate() has already created the intermediate "a.b" node. That does not yet have a Log4j Logger created, so the Logger for "a" is returned. Original log4j would have returned "a.b" due to it using the parent structure in the implementation.


With the log4j bridge, abc.getParent().getName() == "a" but with original log4j it is "a.b". An alternative would be to have Logger.getParent() get the parent node and then convert that back to a Logger (so dropping updateParents() altogether), but I believe that would require Logger to have changes from upstream which it doesn't currently have.

Logger.getParent() isn't particularly well documented as to what it is supposed to do, but the bridge's current behaviour is not identical to Log4J's.

Comment 2 James Perkins 2014-08-19 16:14:44 UTC
Open PR for log4j-jboss-logmanager https://github.com/jboss-logging/log4j-jboss-logmanager/pull/6

Comment 4 Nikoleta Hlavickova 2014-10-22 11:51:38 UTC
Verified with EAP 6.4.0.DR6.


Note You need to log in before you can comment on or make changes to this bug.