获取当前运行的类名,方法名
public static void main(String[] arg)
{
???? try {
??? Test t = new Test();
??? t.Log();
?? } catch (Exception e) {
??? e.printStackTrace();
?? }
}
public void Log()
{
??? System.out.println("方法名?????? "+Thread.currentThread().getStackTrace()[1].getMethodName());
???? System.out.println("类名??? "+Thread.currentThread().getStackTrace()[1].getClassName());
???? System.out.println("文件名?? " + Thread.currentThread().getStackTrace()[1].getFileName());
???? System.out.println("所在的行数 "+Thread.currentThread().getStackTrace()[1].getLineNumber());
}