简体   繁体   中英

How to get full path to method, where it was called in java?

how can I get full path to class, where my method was called. I have a method, which write logs. I want to know, where it was called.

System.getProperty("user.dir") 

will get you the directory. If you want the class name as well use

this.getClass().getName();

I used log.debug("" + Arrays.toString(Thread.currentThread().getStackTrace())); to get full classpath where my method was called from.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM