Overloaded methods in the wrapper, or in the log4j consumer?

In log4j consumer (i.e., our code as using the loig4j library) you would
want it to differentiate the overloaded methods (which is does in either the
orignal code or my code).

Overloaded methods in the wrapper should be fine in either case, because it
is the lastIndexOf method used to determine where to start parsing the stack
trace.



********************************************
Steve Ebersole
IT Integration Engineer
Vignette Corporation 
512.741.4195

Visit http://www.vignette.com

********************************************


-----Original Message-----
From: Tumpach, Andrew J [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 27, 2002 11:49 AM
To: Log4J Users List
Subject: RE: LocationInfo bug


Couldn't a similar problem occur with overloaded methods, where one is
called by another?

Andrew

-----Original Message-----
From: Ebersole, Steven [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 27, 2002 11:22 AM
To: Log4j user list (E-mail)
Subject: LocationInfo bug


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:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to