I uncovered this issue when testing a logging wrapper class using JUnit. The issue occurs when the logging wrapper class I created (called "com.somecompany.util.Logger") is called from the test class (called "com.somecompany.util.LoggerTest"). The wrapper class appropriately passes its fully qualified class name (FQCN) to Log4J, and this name is used to search the stack trace for the last instance of the class. Unfortunately, because com.somecompany.util.LoggerTest includes the substring com.somecompany.util.Logger and appears earlier in the stack trace, its stack frame is being used as the one for the FQCN and the wrong location information is being populated.
*** This bug has been marked as a duplicate of bug 44888 ***