logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <c...@qos.ch>
Subject Re: LocationInfo bug
Date Thu, 27 Jun 2002 17:20:41 GMT
Hi Steve,

It's a well known issue. See LOG4J_HOME/examples/subclass/MyLogger.java 
(the comment before the FCQN variable.)

At 11:22 27.06.2002 -0500, Ebersole, Steven wrote:
>There is a real subtle bug in LocationInfo which can cause log4j itself to
>skip stack frames.
>
>It has to do with how the stack trace is searched.  In the current
>LocationInfo.java at line 111, the following is executed:
>     ibegin = s.lastIndexOf(fqnOfCallingClass);
>where 'fqnOfCallingClass' is suppoed to be the Category or Logger or custom
>wrapper initiating the logging event.
>
>Now consider the following stack trace from my custom classes (made by
>uncommenting line 101 in LocationInfo.java):
>s is [java.lang.Exception
>         at tests.misc.Logger.debug(Logger.java:51)
>         at tests.misc.Logger.debug(Logger.java:46)
>         at tests.misc.LoggerGenerator.main(LoggerGenerator.java:84)
>].
>
>In my custom classes, my wrapper is tests.misc.Logger so that initial search
>(line 111) is really doing:
>     ibegin = s.lastIndexOf( "tests.misc.Logger" );
>
>Of course that also matches "tests.misc.LoggerGenerator" which is the last
>line and so no location info is logged when I run this.
>
>
>The simple work around I did was to modify line 111 as follows:
>     ibegin = s.lastIndexOf( " " + fqnOfCallingClass + "." );
>
>The leading space ensures that the above test would not also match
>"my.tests.misc.Logger".
>
>
>
>********************************************
>Steve Ebersole
>IT Integration Engineer
>Vignette Corporation
>512.741.4195
>
>Visit http://www.vignette.com
>
>********************************************
>
>--
>To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>

--
Ceki


--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


Mime
View raw message