[slf4j-user] What about providing LoggerFactory.getLogger() method?
Ceki Gülcü
listid at qos.ch
Wed Oct 26 13:28:18 CEST 2005
At 01:10 PM 10/26/2005, you wrote:
>Hello Ceki,
>
>2005/10/26, Ceki Gülcü <<mailto:listid at qos.ch>listid at qos.ch>:
>>I think it is a great idea. When you say it would be easy in case of
>>JDK 1.4, are you thinking of the Throwable.fillInStackTrace() method
>>introduced in JDK 1.4? The javadoc for that method states:
>>
>> Some virtual machines may, under some circumstances, omit one or
>> more stack frames from the stack trace. In the extreme case, a virtual
>> machine that has no stack trace information concerning this throwable
>> is permitted to return a zero-length array from this method. Generally
>> speaking, the array returned by this method will contain one element
>> for every frame that would be printed by printStackTrace.
>>
>>If the said "omitted stack frame" is the one identifying the caller,
>>then the logger name computed by LoggerFactory.getLogger() would be
>>wrong, with potentially very unpleasant results. :-)
>>
>>Would you concur?
>
>It seems like the quoted documentation is for 'getStackTrace()' method. :)
Yes, sorry about that. I was thinking of Throwable.getStackTrace() not
Throwable.fillInStackTrace().
>Anyway, you're right. But what about parsing stack trace strings to find
>out the class name? This should work for most virtual machines.
Parsing the trace string presents exactly the same problem. One can assume
that the lost frames are due to optimizations by the JVM and not caused by
how Throwable.getStackTrace() reports the frames. If
Throwable.getStackTrace() has missing frames then so will the stack trace
output by Throwable.printStackTrace (and one cannot parse what is missing.)
>In case of failure we could throw a RuntimeException to trigger
>ExceptionInitializerError.
Failure is not an option. :-)
A logging system is supposed to increase the confidence you have in your
software, it can't be a source of trouble in its own right.
>Trustin
>--
--
Ceki Gülcü
The complete log4j manual: http://www.qos.ch/log4j/
Improve your Sudoku skills at http://www.sudoku-grok.com/
More information about the slf4j-user
mailing list