package cn.com.utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CurrentUtils { private static final Logger LOGGER = LoggerFactory.getLogger(CurrentUtils.class); /** * @Title: getCurrentClassAndMethodName * @Description: 获取调用方法的行号+类名+方法名 * @return String 返回类型 */ public static String getCurClassMethodName() { StringBuilder result = new StringBuilder(); try { StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[2]; String className = stackTraceElement.getClassName(); String methodName = stackTraceElement.getMethodName(); result.append(className).append(".").append(methodName); } catch (Exception e) { LOGGER.info(e.getMessage()); } return result.toString(); } }