How can I get the current stack trace in Java?

前端 未结 21 3882
耶瑟儿~
耶瑟儿~ 2020-11-21 23:49

How do I get the current stack trace in Java, like how in .NET you can do Environment.StackTrace?

I found Thread.dumpStack() but it is not what I want -

21条回答
  •  我在风中等你
    2020-11-22 00:21

    This is an old post, but here is my solution :

    Thread.currentThread().dumpStack();
    

    More info and more methods there : http://javarevisited.blogspot.fr/2013/04/how-to-get-current-stack-trace-in-java-thread.html

提交回复
热议问题