How to print Java object's current value to console, instead of suspend thread while debug in the Eclipse?

509 views Asked by At

Sometimes you need just to check how are some values in your application changing in time. Usually, you can use the log, but imagine that your application is on severs already and make the whole CI/CD cycle, just to add a few temporary log statements is overkill. Or variables are in 3-rd party libraries, and you don't want to patch it.

Of course, you can (remotely) debug your application, but it may be an issue to suspend the thread and check several variables again and again and again.

Such functionality is available in the JetBrains IntelliJ IDEA out of the box - tracepoint, but what about Eclipse?

1

There are 1 answers

0
foal On BEST ANSWER

Fortunately, you can implement the "virtual logging" with Eclipse.

To do it:

  1. Start the debug session
  2. add the conditional breakpoint to the line that you want to add a log statement
  3. Write the log statement to the breakpoint condition and return false;

enter image description here

That's all. The application will not suspend while passing breakpoint but will write to output the value of the variable