Java Logback不';不显示堆栈跟踪

Java Logback不';不显示堆栈跟踪,java,spring,jetty,spring-boot,logback,Java,Spring,Jetty,Spring Boot,Logback,我使用的是SpringBoot1.2.0,在控制台中没有看到异常堆栈跟踪 其他一切都被记录下来,SQL、事务启动和回滚(当异常发生时),但我没有看到它们。有人有什么想法吗 资源文件夹中的logback.xml <?xml version="1.0" encoding="UTF-8"?> <configuration debug="true" scan="true"> <jmxConfigurator/> <include resource="org/s

我使用的是SpringBoot1.2.0,在控制台中没有看到异常堆栈跟踪

其他一切都被记录下来,SQL、事务启动和回滚(当异常发生时),但我没有看到它们。有人有什么想法吗

资源文件夹中的logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true" scan="true">
<jmxConfigurator/>

<include resource="org/springframework/boot/logging/logback/base.xml"/>

<logger name="org.apt.crm" level="DEBUG"/>
<logger name="org.springframework" level="ERROR"/>
<logger name="org.hibernate" level="ERROR"/>
<logger name="org.springframework.orm.jpa" level="ERROR"/>
<logger name="org.springframework.transaction" level="DEBUG"/>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
</appender>

<root level="INFO">
    <appender-ref ref="STDOUT"/>
</root>

</configuration>
服务器启动时的控制台输出

:37:38,267 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
:37:38,268 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
:37:38,268 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/Clowio/apt-crm/src/main/resources/logback.xml]
:37:38,525 |-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[/Clowio/apt-crm/src/main/resources/logback.xml]] every 60 seconds. 
:37:38,525 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter
:37:38,536 |-INFO in ch.qos.logback.classic.joran.action.JMXConfiguratorAction - begin
:37:38,620 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@71d44a3 - Adding [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/base.xml] to configuration watch list.
:37:38,620 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@7b98f307 - URL [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/base.xml] is not of type file
:37:38,624 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@71d44a3 - Adding [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml] to configuration watch list.
:37:38,624 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@7b98f307 - URL [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml] is not of type file
:37:38,628 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word clr with class [org.springframework.boot.logging.logback.ColorConverter]
:37:38,628 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word wex with class [org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter]
:37:38,634 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [org.springframework.boot.logging.logback.LevelRemappingAppender]
:37:38,637 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [DEBUG_LEVEL_REMAPPER]
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.startup.DigesterFactory] to ERROR
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.util.LifecycleBase] to ERROR
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.coyote.http    .Http    NioProtocol] to WARN
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.sshd.common.util.SecurityUtils] to WARN
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.tomcat.util.net.NioSelectorPool] to WARN
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.crsh.plugin] to WARN
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.crsh.ssh] to WARN
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.eclipse.jetty.util.component.AbstractLifeCycle] to ERROR
:37:38,668 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate.validator.internal.util.Version] to WARN
:37:38,668 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration] to WARN
:37:38,668 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework.boot.actuate.endpoint.jmx] to false
:37:38,668 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DEBUG_LEVEL_REMAPPER] to Logger[org.springframework.boot.actuate.endpoint.jmx]
:37:38,669 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.thymeleaf] to false
:37:38,670 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DEBUG_LEVEL_REMAPPER] to Logger[org.thymeleaf]
:37:38,670 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@71d44a3 - Adding [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/console-appender.xml] to configuration watch list.
:37:38,671 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@7b98f307 - URL [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/console-appender.xml] is not of type file
:37:38,673 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
:37:38,678 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]
:37:38,694 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
:37:38,769 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@71d44a3 - Adding [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/file-appender.xml] to configuration watch list.
:37:38,769 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@7b98f307 - URL [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/file-appender.xml] is not of type file
:37:38,773 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
:37:38,778 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
:37:38,789 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
:37:38,809 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@2177849e - No compression will be used
:37:38,821 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Active log file name: /var/folders/j4/ntrxjqzx5kq19hbxfwc10czc0000gn/T//spring.log
:37:38,822 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - File property is set to [/var/folders/j4/ntrxjqzx5kq19hbxfwc10czc0000gn/T//spring.log]
:37:38,823 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
:37:38,823 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[ROOT]
:37:38,823 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT]
:37:38,824 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apt.crm] to DEBUG
:37:38,824 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework] to ERROR
:37:38,824 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate] to ERROR
:37:38,824 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.orm.jpa] to ERROR
:37:38,824 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.transaction] to DEBUG
:37:38,824 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
:37:38,824 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
:37:38,824 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
:37:38,826 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
:37:38,826 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
:37:38,826 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
:37:38,826 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@10959ece - Registering current configuration as safe fallback point

解决这个问题的办法是:


创建ExceptionMapper后,一切正常。

很少有问题-这种情况是针对所有类型的异常,还是只针对其中一种或几种类型(如NullPointerException)发生?试着做一个测试来理解这一点。另外,您是否在日志中看到了没有stacktrace的异常类型,或者没有日志中关于异常的信息?最后,这只是关于异常堆栈跟踪还是关于在错误日志级别下记录的消息?对于任何类型的异常都不会显示堆栈跟踪。代码中没有任何类型的异常或错误的痕迹,只在WS返回代码500。带有调试或错误的日志将正常显示。我将尝试创建自己的异常处理,也许Jetty会吃掉它们:p
:37:38,267 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
:37:38,268 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
:37:38,268 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/Clowio/apt-crm/src/main/resources/logback.xml]
:37:38,525 |-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[/Clowio/apt-crm/src/main/resources/logback.xml]] every 60 seconds. 
:37:38,525 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter
:37:38,536 |-INFO in ch.qos.logback.classic.joran.action.JMXConfiguratorAction - begin
:37:38,620 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@71d44a3 - Adding [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/base.xml] to configuration watch list.
:37:38,620 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@7b98f307 - URL [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/base.xml] is not of type file
:37:38,624 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@71d44a3 - Adding [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml] to configuration watch list.
:37:38,624 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@7b98f307 - URL [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml] is not of type file
:37:38,628 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word clr with class [org.springframework.boot.logging.logback.ColorConverter]
:37:38,628 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word wex with class [org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter]
:37:38,634 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [org.springframework.boot.logging.logback.LevelRemappingAppender]
:37:38,637 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [DEBUG_LEVEL_REMAPPER]
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.startup.DigesterFactory] to ERROR
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.util.LifecycleBase] to ERROR
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.coyote.http    .Http    NioProtocol] to WARN
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.sshd.common.util.SecurityUtils] to WARN
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.tomcat.util.net.NioSelectorPool] to WARN
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.crsh.plugin] to WARN
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.crsh.ssh] to WARN
:37:38,667 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.eclipse.jetty.util.component.AbstractLifeCycle] to ERROR
:37:38,668 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate.validator.internal.util.Version] to WARN
:37:38,668 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration] to WARN
:37:38,668 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework.boot.actuate.endpoint.jmx] to false
:37:38,668 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DEBUG_LEVEL_REMAPPER] to Logger[org.springframework.boot.actuate.endpoint.jmx]
:37:38,669 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.thymeleaf] to false
:37:38,670 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DEBUG_LEVEL_REMAPPER] to Logger[org.thymeleaf]
:37:38,670 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@71d44a3 - Adding [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/console-appender.xml] to configuration watch list.
:37:38,671 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@7b98f307 - URL [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/console-appender.xml] is not of type file
:37:38,673 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
:37:38,678 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]
:37:38,694 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
:37:38,769 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@71d44a3 - Adding [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/file-appender.xml] to configuration watch list.
:37:38,769 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@7b98f307 - URL [jar:file:/Users/lalala/.m2/repository/org/springframework/boot/spring-boot/1.2.0.RELEASE/spring-boot-1.2.0.RELEASE.jar!/org/springframework/boot/logging/logback/file-appender.xml] is not of type file
:37:38,773 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
:37:38,778 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
:37:38,789 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
:37:38,809 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@2177849e - No compression will be used
:37:38,821 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Active log file name: /var/folders/j4/ntrxjqzx5kq19hbxfwc10czc0000gn/T//spring.log
:37:38,822 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - File property is set to [/var/folders/j4/ntrxjqzx5kq19hbxfwc10czc0000gn/T//spring.log]
:37:38,823 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
:37:38,823 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[ROOT]
:37:38,823 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT]
:37:38,824 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apt.crm] to DEBUG
:37:38,824 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework] to ERROR
:37:38,824 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate] to ERROR
:37:38,824 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.orm.jpa] to ERROR
:37:38,824 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.transaction] to DEBUG
:37:38,824 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
:37:38,824 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
:37:38,824 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
:37:38,826 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
:37:38,826 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
:37:38,826 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
:37:38,826 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@10959ece - Registering current configuration as safe fallback point