如何获得在 java 中被调用的方法的完整路径?
How to get full path to method, where it was called in java?
如何获得调用我的方法的 class 的完整路径。我有一个方法,它写日志。我想知道它是在哪里调用的。
System.getProperty("user.dir")
将为您获取目录。
如果您还想要 class 名称,请使用
this.getClass().getName();
我使用 log.debug("" + Arrays.toString(Thread.currentThread().getStackTrace()));
获取调用我的方法的完整类路径。
如何获得调用我的方法的 class 的完整路径。我有一个方法,它写日志。我想知道它是在哪里调用的。
System.getProperty("user.dir")
将为您获取目录。 如果您还想要 class 名称,请使用
this.getClass().getName();
我使用 log.debug("" + Arrays.toString(Thread.currentThread().getStackTrace()));
获取调用我的方法的完整类路径。