Hi Ralph,
On 11/05/16 18:14, Ralph Goers wrote:
You are correct that most of the time it would be faster to start from frame 0.
However, the problem we have with walking the stack from frame 0 is that it is
possible to have a situation like
Foo::method1—>Logger.log—>BarAppender.append—>Foo::method2 (or even method1
again)—>Logger.log
The appender would call Logger.log? Is that a common situation?
That sounds strange to me.
I was kind of assuming that you could walk the stack until
finding an instance of Logger (which would allow you to skip
all the appender's infrastructure), then continue walking until
you find something which is no longer a Logger.
I'm not sure I understand your other comment about getCallerClass().
That just walks 2 frames (skipping reflection frame).
You can do the same with StackWalker, that should enable you
to get the calling frame easily.
best regards,
-- daniel