java.util.loggingLogRecord#inferCaller()
を参考にすると
public static void hoge(){ StackTraceElement stack[] = (new Throwable()).getStackTrace(); // First, search back to a method in the Logger class. int ix = 0; while (ix < stack.length) { StackTraceElement frame = stack[ix]; String cname = frame.getClassName(); if (cname.equals("java.util.logging.Logger")) { break; } ix++; } // Now search for the first frame before the "Logger" class. while (ix < stack.length) { StackTraceElement frame = stack[ix]; String cname = frame.getClassName(); if (!cname.equals("java.util.logging.Logger")) { // We've found the relevant frame. // setSourceClassName(cname); // setSourceMethodName(frame.getMethodName()); System.out.println(cname); System.out.println(frame.getMethodName()); return; } ix++; } }
で呼び出し元がわかる
[通知用URL]
Tweet
最終更新時間:2008年05月25日 22時04分49秒