logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 44888] problem in showing Filename and Line number in log file
Date Fri, 16 May 2008 07:49:47 GMT

--- Comment #6 from Ralph Goers <rgoers@apache.org>  2008-05-16 00:49:47 PST ---
I ran the build and it was successful. I modified the Appender code I showed
below to print the stacktrace and the info in LocationInfo before it was
corrected. From that I was able to determine what the problem is. The code is
only matching up to a class name the length of the FQCN. In the case below that
means it matches LoggerUtilTest when it shouldn't have. I modified
LocationInfoTest with a new test case and created a new class to simulate the
behvior and it failed. If included both after the stack trace.

I'll still look into creating a Java 5 version of this. However you fix this
for 1.3 is just going to make it even slower.

className: sun.reflect.NativeMethodAccessorImpl
filename: ?
lineNumber: ?
methodName: invoke0
FQCN: com.diginsite.services.logging.LoggerUtil
        at org.apache.log4j.Category.callAppenders(Category.java:206)
        at org.apache.log4j.Category.forcedLog(Category.java:391)
        at org.apache.log4j.Category.log(Category.java:856)
        at org.slf4j.impl.Log4jLoggerAdapter.log(Log4jLoggerAdapter.java:509)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

new test case for LocationInfoTest.java

     * Tests creation of location info from a throwable and where the
     * FQCN is part of the caller's name.
    public void testLocationInfo() {
        LocationInfo li = new LocationIn().getLocationInfo();
        final String className = LocationInfoTest.class.getName();
        final String methodName = "testLocationInfo";
        final String fileName = "LocationInfoTest.java";
        final String lineNumber = "49";
        assertEquals(className, li.getClassName());
        assertEquals(methodName, li.getMethodName());
        assertEquals(fileName, li.getFileName());
        assertEquals(lineNumber, li.getLineNumber());
        assertEquals(className + "."  + methodName
                + "(" + fileName + ":" + lineNumber + ")",


package org.apache.log4j.spi;

public class LocationIn
    public LocationInfo getLocationInfo()
       Throwable t = new Throwable();
       String fqcn = LocationIn.class.getName();
       return new LocationInfo(t, fqcn);

Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message