简体   繁体   English

Tomcat 应用程序日志未显示完整的堆栈跟踪

[英]Tomcat Application Log not showing full stacktrace

Got an web application running on Tomcat.在 Tomcat 上运行了一个 Web 应用程序。 I log exceptions and their stack traces using slf4j/logback.我使用 slf4j/logback 记录异常及其堆栈跟踪。 eg例如

2017-08-01 00:00:00.000 [http-nio-80-exec-5] ERROR g.s.GuiceyRequestFactoryServlet - 'Server Failure'
java.lang.reflect.InvocationTargetException: null
...
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.33]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_131]
Caused by: ...
    ... 59 common frames omitted
Caused by: ...
    ... 64 common frames omitted
java.lang.NullPointerException: null

Because the real place that caused the NPE is nested a few level down within at least two reflection invocations, not sure if thats the case, Tomcat/slf4j/logback does not show the full stacktrace and stopped at the NPE, not further down.因为导致 NPE 的实际位置至少在两次反射调用中嵌套了几层,不确定是否是这种情况,Tomcat/slf4j/logback 没有显示完整的堆栈跟踪并在 NPE 处停止,而不是进一步向下。

I am expecting something like eg我期待像这样的东西

2017-08-01 00:00:00.000 [http-nio-80-exec-5] ERROR g.s.GuiceyRequestFactoryServlet - 'Server Failure'
java.lang.reflect.InvocationTargetException: null
...
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.33]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_131]
Caused by: ...
    ... 59 common frames omitted
Caused by: ...
    ... 64 common frames omitted
Caused by: java.lang.NullPointerException: null
    at java.util.Calendar.setTime(Calendar.java:1770) ~[na:1.8.0_60]
    ... 80 common frames omitted

ie to show a deeper stacktrace in the log.即在日志中显示更深的堆栈跟踪。 Does anyone know where should I look at and how to achieve that?有谁知道我应该在哪里看以及如何实现? eg Tomcat config?例如Tomcat配置? logback config?登录配置? slf4j methods? slf4j 方法?

Edit编辑

For those thinking this is a duplication of some other question asking about those "... xx common frames omitted", NO, I do not care these lines.对于那些认为这是一些其他问题的重复,询问那些“...... xx 公共帧被省略”,不,我不在乎这些行。 I was asking about the last NPE not being printed AT ALL.我问的是最后一个 NPE 根本没有打印出来。 Please ready carefully first.请先仔细准备。

这应该可以使用 -XX:-OmitStackTraceInFastThrow 选项。

The ... 59 more frames ommitted only means that these exceptions were already printed before. ... 省略了 59 多帧仅意味着之前已经打印了这些异常。 In Logback you can restructure stack track to avoid duplicates and print stack lines always in correct order.在 Logback 中,您可以重构堆栈轨道以避免重复并始终以正确的顺序打印堆栈行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM