You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Ron Blaschke <ma...@rblasch.org> on 2003/11/24 15:06:55 UTC
Re[3]: log4j location information issue
Any opinions on that one?
CG>> Since you are familiar with the relevant log4j code, do you know the stack
CG>> trace lines look like?
RB> Not an easy question. In Java 1.4.2, Sun implements the information as either
RB> (<Filename>:<LineNumber>)
RB> (<Filename>)
RB> (Native Method)
RB> (Unknown Source)
RB> (see
RB> http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StackTraceElement.html#toString())
RB> In 1.3.1 the implementation is similar, but directly in the VM (in
RB> method pc2string in classruntime.c).
RB> I'd recommend changing the code to the one below, which would leave
RB> "Native Method" and "Unknown Source" as is. Replacing "Unknown Source"
RB> with NA might be considered, though.
RB> public
RB> String getFileName() {
RB> if(fullInfo == null) return NA;
RB> if(fileName == null) {
RB> int iend = fullInfo.lastIndexOf(':');
RB> if(iend == -1) {
RB> iend = fullInfo.lastIndexOf(')');
RB> }
RB> if (iend == -1) {
RB> fileName = NA;
RB> } else {
RB> int ibegin = fullInfo.lastIndexOf('(', iend - 1);
RB> fileName = this.fullInfo.substring(ibegin + 1, iend);
RB> }
RB> }
RB> return fileName;
RB> }
Ron
--
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org