Reputation: 2364
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?
Upvotes: 1
Views: 871
Reputation: 1985
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;
(Best way to write String to file using java nio)
Upvotes: 1
Reputation: 2617
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;
Upvotes: 3