如何停止堆栈跟踪在日志中截断

2022-08-31 12:00:39

很多时候,在Java日志中,我会得到这样的东西:

Caused by: java.sql.BatchUpdateException: failed batch
    at org.hsqldb.jdbc.jdbcStatement.executeBatch(jdbcStatement.java:1102)
    at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(jdbcPreparedStatement.java:514)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
    ... 113 more

有谁知道如何显示完整的堆栈跟踪(即显示其他113行)?


用于 Throwable 的 JavaDocs(用于 Java 7)对正在发生的事情有非常详细的解释。


答案 1

当您看到“...113 更多“,这意味着”由“异常的其余行与父异常的该点开始的其余行相同。

例如,您将拥有

com.something.XyzException
  at ...
  at ...
  at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
  at ... <the other 113 lines are here>...
Caused by: <the above>.

两个堆栈跟踪在 AbstractBatcher.executeBatch,第 242 行“相遇”,然后从那时起,向上调用跟踪与包装异常相同。


答案 2

增加 JVM 选项。-XX:MaxJavaStackTraceDepth


推荐