【发布时间】:2020-11-05 15:55:36
【问题描述】:
请建议我如何用 log.error 替换 printstacktace 行
public class extends Throwable {
private Throwable _prev;
public synchronized Throwable getPrevThrowable() {
return _prev;
}
public void printStackTrace(PrintStream ps) {
super.printStackTrace(ps);
Throwable t;
if ((t = getPrevThrowable()) != null) {
t.printStackTrace(ps);
}
}
我可以像下面这样实现吗??
public class extends Throwable {
public void printStackTrace(PrintStream ps) {
log.error(ps);
Throwable t;
if ((t = getPrevThrowable()) != null) {
log.error(t);
}
}
【问题讨论】:
-
只需将异常传递给您的记录器。您正在使用的日志框架应该提供有关此的文档。
标签: javascript java log4j log4j2 printstacktrace