logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ronald Blaschke <mailing-li...@rblasch.org>
Subject Re[2]: log4j location information issue
Date Sun, 16 Nov 2003 00:00:12 GMT
Hello Ceki,

CG> Ronald,

CG> Since you are familiar with the relevant log4j code, do you know the stack
CG> trace lines look like?

Not an easy question.  In Java 1.4.2, Sun implements the information as either
(<Filename>:<LineNumber>)
(<Filename>)
(Native Method)
(Unknown Source)

(see http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StackTraceElement.html#toString())

In 1.3.1 the implementation is similar, but directly in the VM (in
method pc2string in classruntime.c).

I'd recommend changing the code to the one below, which would leave
"Native Method" and "Unknown Source" as is.  Replacing "Unknown Source"
with NA might be considered, though.

    public
    String getFileName() {
        if(fullInfo == null) return NA;

        if(fileName == null) {
            int iend = fullInfo.lastIndexOf(':');
            if(iend == -1) {
                iend = fullInfo.lastIndexOf(')');
            }

            if (iend == -1) {
                fileName = NA;
            } else {
                int ibegin = fullInfo.lastIndexOf('(', iend - 1);
                fileName = this.fullInfo.substring(ibegin + 1, iend);
            }
        }
        return fileName;
    }
    
Ron


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


Mime
View raw message