更新:您最好使用您发现的IDE断点.
否则,您可以设置自定义PrintStream通道System.setOut(..),在那里,无论何时打印,也打印Thread.currentThread().getStackTrace()
理想情况下,您PrintStream应该将原始包裹System.out并发送给它.就像是:
public class PrintStreamWrapper extends PrintStream {
public PrintStreamWrapper(OutputStream out) {
super(out);
}
public void println(String x) {
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
// print everything, but not to the System.out,
// because you'll end up in a loop.
super.println(x);
}
}
Run Code Online (Sandbox Code Playgroud)
然后,在您的计划开始时:
System.setOut(new PrintStreamWrapper(System.out));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1105 次 |
| 最近记录: |