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.
Asked
Active
Viewed 246 times
0
-
2Possible duplicate of: http://stackoverflow.com/questions/227486/find-where-java-class-is-loaded-from – burglarhobbit Sep 09 '15 at 14:03
-
Ok, I had to call Thread.currentThread().getStackTrace(). – Sergei Podlipaev Sep 09 '15 at 14:08
-
@SergeiPodlipaev If you believe you have solved your issue on your own it would be good if you answer your question yourself. If you have used information from other sources ideally you would mark the answer as `Community Wiki`. This way it will appear as solved. – Phantomazi Sep 09 '15 at 14:14
2 Answers
0
System.getProperty("user.dir")
will get you the directory. If you want the class name as well use
this.getClass().getName();

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

Sergei Podlipaev
- 1,331
- 1
- 14
- 34