Call trace in java

前端 未结 8 2161
野趣味
野趣味 2020-12-05 11:38

Is there a way to output a call trace for a particular thread in java?

I do not want a stack trace. I would like a sequence of calls on each object for tracing.

相关标签:
8条回答
  • 2020-12-05 12:00

    You'd basically want aspect-oriented programming of some form, where the aspect could determine whether the current thread was meant to be logging calls. (The alternative is to explicitly put the logging in every method yourself, which would be painful.)

    There are plenty of AOP frameworks in Java, such as AspectJ and Spring (Spring is a lot more than AOP of course).

    Applying aspects to every method call in the system could be tricky though... I don't have any experience with AspectJ, but Spring AOP is basically designed to enable AOP around the components. Classes which are effectively unknown to Spring can't be changed easily. Mind you, it's been a while since I've used even Spring AOP - things may have come on since then :)

    0 讨论(0)
  • 2020-12-05 12:11

    If you're using IntelliJ, there is plugin called Flameviewer. Please find more details on the below link,

    https://github.com/kornilova-l/FlameViewer#uploading-file-to-flameviewer

    0 讨论(0)
提交回复
热议问题