/** * 獲取調用方的class * @return */ private static String getInvoke() { StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); StackTraceElement log = stackTrace[1]; String tag = null; for (int i = 1; i < stackTrace.length; i++) { StackTraceElement e = stackTrace[i]; if (!e.getClassName().equals(log.getClassName())) { tag = e.getClassName(); break; } } if (tag == null) { tag = log.getClassName(); } return tag; }