[prev in list] [next in list] [prev in thread] [next in thread] 

List:       log4j-dev
Subject:    org.apache.log4j.spi.LocationInfo
From:       tejasvi m <morphiusx () usa ! net>
Date:       2001-05-22 4:22:03
[Download RAW message or body]

I found this while building a wrapper around log4j. All classes in my package
call a factory to get a Tracer instance (which is nothing but a container
object for a Category). Then a method call is made on the Tracer, which
delegates it to the Category instance it contains.

To ensure that the %C token for caller class identification works fine, (and
does'nt print 'mypackage.Tracer' all the time) and to incorporate other
functionality I had, I extended Category to create MyCategory, a corresponding
MyLoggingEvent and MyCategoryFactory. 

Apart from other things, I also added this line in MyCategory.java:

private static String FQCN = Tracer.class.getName(); 

which is "mypackage.Tracer".

And to test this I wrote a TracerTest in the same package.

When I ran it, the LocationInfo threw a NullPointerException. Coz, the last 2
lines in the Throwable object look like this:

at mypackage.Tracer.log(Tracer.java:34)
at mypackage.TracerTest.main(TracerTest.java:22)

Line 116 of LocationInfo.java (revision 1.5) is:
ibegin = s.lastIndexOf(fqnOfCallingClass);

This causes the index to jump to the last line of the StackTrace, whereas the
intention was to get it to the earlier line. (It only happens when the name
the caller contains the name of our FQCN String.

So Line 116 in LocationInfo.java should be changed to:

ibegin = s.lastIndexOf(fqnOfCallingClass + ".");



Cheers


____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic