Java tutorial
//package com.java2s; public class Main { public static String getCallerNoPackageClassNameMethod() { final StackTraceElement el = Thread.currentThread().getStackTrace()[2]; final String noPackageClassName = el.getClassName().replaceAll(".*\\.", ""); final String methodName = el.getMethodName(); final String retval = noPackageClassName + "." + methodName; return retval; } public static String getMethodName() { return Thread.currentThread().getStackTrace()[1].getMethodName(); } }