private static FrameInfo getLoggingFrame ( ) { StackTraceElement [ ] stackTrace = Thread . currentThread ( ) . getStackTrace ( ) ; StackTraceElement loggingFrame = null ; /* * We need to dig through all the frames until we get to a frame that contains this class, then dig through all * frames for this class, to finally come to a point where we have the frame for the calling method. */ // Skip stackTrace[0], which is getStackTrace() on Win32 JDK 1.6. for ( int ix = 1 ; ix < stackTrace . length ; ix ++ ) { loggingFrame = stackTrace [ ix ] ; if ( loggingFrame . getClassName ( ) . contains ( CLASS_NAME ) ) { for ( int iy = ix ; iy < stackTrace . length ; iy ++ ) { loggingFrame = stackTrace [ iy ] ; if ( ! loggingFrame . getClassName ( ) . contains ( CLASS_NAME ) ) { break ; } } break ; } } return new FrameInfo ( loggingFrame . getClassName ( ) , loggingFrame . getMethodName ( ) ) ; }
Calculate the logging frame s class name and method name .