0

I want to see what lines of code are being executed in my Java program when it runs and terminates. One way I can do this is by using an IDE such as IntelliJ or Eclipse and setting a break point in the main method, then going through each line of code one after another using the step-over and step-into buttons. This becomes extremely tedious to do after a while though, because the program freezes every time I want to know what line of code is executed next.

Is there another way to see what's happening in my Java program, other than using an IDE debugger and setting breakpoints? I would also like to be able to use my program like a normal user would be able to (i.e. not being paused every few seconds because of my IDE).

martinez314
  • 12,162
  • 5
  • 36
  • 63
zxgear
  • 1,168
  • 14
  • 30
  • 2
    `java.util.logging` or log4j or slf4j? – OneCricketeer Jun 20 '16 at 20:36
  • I mean, if you really wanted to keep it simple, you could just use `System.out.println` instead of a fancy logger if it's for sanity checking. – Compass Jun 20 '16 at 20:37
  • I'm aware of `System.out` and various logging frameworks, but they are also tedious to use in this case. Instead of writing log statements everywhere in my codebase, I just need to know which methods/LOC are being called. – zxgear Jun 20 '16 at 20:41
  • AspectJ could help you: http://stackoverflow.com/questions/12732069/how-to-automatically-log-the-entry-exit-of-methods-in-java – sinclair Jun 20 '16 at 20:43
  • First off, you should already have log messages being pushed out. Secondly , the way you describe it, no it's not possible. If you want to know which methods are being called as a `normal user` without debugging then logs are you only choice because breakpoints won't exist. – Richard Barker Jun 20 '16 at 20:56

0 Answers0