Is it possible to create some sort of "trace breakpoint" in eclipse whereby Eclipse will log variables that I choose to a file when a "breakpoint" is hit without pausing the application?
Asked
Active
Viewed 695 times
2 Answers
3
Sure. For this sample method:
public static void logArgs(final String one, final String two) {
System.out.println(one + two);
}
put your breakpoint in it, right click it and edit Breakpoint properties...
as in the example. The important checkboxes are Conditional
and Suspend when 'true'
. Just return false
so that breakpoint does not suspend at all.
java.io.FileWriter w = new java.io.FileWriter("/tmp/file.txt", true);
w.write(String.format("args(%s, %s)%n"), one, two));
w.close();
return false;

Benjamin Confino
- 2,344
- 3
- 26
- 30

Michał Grzejszczak
- 2,599
- 1
- 23
- 28
-
1Great answer. And if you write all four statements on one line, it also works in the expression view. – weberjn May 25 '22 at 15:06
1
For Java 11 Michał Grzejszczak's answer can be written as
java.nio.file.Files.writeString(java.nio.file.Path.of("f.txt"), "My string to save");return true;

weberjn
- 1,840
- 20
- 24