Spring Cloud Gateway全局异常处理/记录

时间:2019-01-25 06:31:08

标签: spring logging error-handling spring-webflux spring-cloud-gateway

我有一个Spring Cloud Gateway应用程序,它充当我的数据服务的网关。我的应用程序使用SSE在UI中推送通知。当我看到网关的日志时,我的日志充满了异常,例如:

 2019-01-25 07:39:13,807 ERROR [reactor-http-nio-3] org.springframework.web.server.adapter.HttpWebHandlerAdapter : Unhandled failure: Connection reset by peer, response
already set (status=200)
2019-01-25 07:39:13,809 ERROR [reactor-http-nio-3] org.springframework.http.server.reactive.ReactorHttpHandlerAdapter : Handling completed with error
java.io.IOException: Connection reset by peer
        at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_181]
        at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_181]
        at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_181]
        at sun.nio.ch.IOUtil.write(IOUtil.java:51) ~[na:1.8.0_181]
        at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) ~[na:1.8.0_181]
        at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:403) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:934) [netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:360) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:901) [netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1376) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.handler.ssl.SslHandler.forceFlush(SslHandler.java:1746) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.handler.ssl.SslHandler.wrapAndFlush(SslHandler.java:757) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:734) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.flush(CombinedChannelDuplexHandler.java:533) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.ChannelOutboundHandlerAdapter.flush(ChannelOutboundHandlerAdapter.java:115) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]

-----------------------------------------------------------------------------------------------------------------

2019-01-25 07:40:37,432 ERROR [reactor-http-nio-1] reactor.ipc.netty.channel.CloseableContextHandler : Handler failure while no child channelOperation was present
javax.net.ssl.SSLException: handshake timed out
        at io.netty.handler.ssl.SslHandler.handshake(...)(Unknown Source) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
2019-01-25 07:40:39,512 ERROR [reactor-http-nio-3] org.springframework.web.server.adapter.HttpWebHandlerAdapter : Unhandled failure: Connection reset by peer, response
already set (status=200)
2019-01-25 07:40:39,513 ERROR [reactor-http-nio-3] org.springframework.http.server.reactive.ReactorHttpHandlerAdapter : Handling completed with error
java.io.IOException: Connection reset by peer
        at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_181]
        at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_181]
        at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_181]
        at sun.nio.ch.IOUtil.write(IOUtil.java:51) ~[na:1.8.0_181]
        at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) ~[na:1.8.0_181]
        at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:403) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:934) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:360) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:901) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1376) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.handler.ssl.SslHandler.forceFlush(SslHandler.java:1746) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.handler.ssl.SslHandler.wrapAndFlush(SslHandler.java:757) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:734) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.flush(CombinedChannelDuplexHandler.java:533) ~[netty-transport-4.1.22.Final.jar
!/:4.1.22.Final]
        at io.netty.channel.ChannelOutboundHandlerAdapter.flush(ChannelOutboundHandlerAdapter.java:115) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.CombinedChannelDuplexHandler.flush(CombinedChannelDuplexHandler.java:358) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.ChannelDuplexHandler.flush(ChannelDuplexHandler.java:117) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]

----------------------------------------------------------------------------------------------------------------------------------------------


2019-01-25 07:43:47,048 ERROR [reactor-http-nio-3] org.springframework.web.server.adapter.HttpWebHandlerAdapter : Unhandled failure: Connection reset by peer, response
already set (status=200)
2019-01-25 07:43:47,049 ERROR [reactor-http-nio-3] org.springframework.http.server.reactive.ReactorHttpHandlerAdapter : Handling completed with error
java.io.IOException: Connection reset by peer
        at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_181]
        at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_181]
        at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_181]
        at sun.nio.ch.IOUtil.write(IOUtil.java:51) ~[na:1.8.0_181]
        at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) ~[na:1.8.0_181]
        at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:403) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:934) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:360) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:901) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1376) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.handler.ssl.SslHandler.forceFlush(SslHandler.java:1746) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.handler.ssl.SslHandler.wrapAndFlush(SslHandler.java:757) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:734) ~[netty-handler-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.flush(CombinedChannelDuplexHandler.java:533) ~[netty-transport-4.1.22.Final.jar
!/:4.1.22.Final]
        at io.netty.channel.ChannelOutboundHandlerAdapter.flush(ChannelOutboundHandlerAdapter.java:115) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.CombinedChannelDuplexHandler.flush(CombinedChannelDuplexHandler.java:358) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.ChannelDuplexHandler.flush(ChannelDuplexHandler.java:117) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) ~[netty-transport-4.1.22.Final.jar!/:4.1.22.Final]
        at reactor.ipc.netty.channel.ChannelOperationsHandler.doWrite(ChannelOperationsHandler.java:296) ~[reactor-netty-0.7.5.RELEASE.jar!/:0.7.5.RELEASE]
        at reactor.ipc.netty.channel.ChannelOperationsHandler.drain(ChannelOperationsHandler.java:465) ~[reactor-netty-0.7.5.RELEASE.jar!/:0.7.5.RELEASE]
        at reactor.ipc.netty.channel.ChannelOperationsHandler.flush(ChannelOperationsHandler.java:191) ~[reactor-netty-0.7.5.RELEASE.jar!/:0.7.5.RELEASE]

我有一个错误处理程序类:

import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebExceptionHandler;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.io.IOException;

@Component
public class GlobalExceptionHandler implements WebExceptionHandler {

    @Override
    public Mono<Void> handle(ServerWebExchange exchange, Throwable exception) {
        if (exchange.getResponse().isCommitted()) {
            //for SSE connections, privents from filling up logs when connection is closed.
            if(exception instanceof IOException && (exception.getMessage().contains("An established connection was aborted") || exception.getMessage().contains("Connection closed prematurely"))){
                return exchange.getResponse().writeWith(Flux.just());
            }
        }
        return Mono.error(exception);
    }
}

,但它仍在记录错误。如何使我的网关不写日志。

我的pom文件是:

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>microservices-api-gateway</artifactId>
    <version>2.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>api-gateway</name>
    <description>description</description>

    <parent>
        <artifactId>project-parent-pom</artifactId>
        <groupId>xxx.xx</groupId>
        <version>1.0.0</version>
    </parent>

    <dependencyManagement>

        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>2.0.0.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-gateway-core
            Due to defect in previous version higher version of cloud gateway was used-->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-gateway-core</artifactId>
                <version>2.0.1.RELEASE</version>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
        <env.properties>config/${environment}_env.properties</env.properties>
        <resources.version>3.0.2</resources.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <!--<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>-->
        <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-hystrix -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security.oauth.boot</groupId>
            <artifactId>spring-security-oauth2-autoconfigure</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.0.0.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
</project>

我的依赖树:

 com.vh:microservices-api-gateway:jar:2.0.0-SNAPSHOT
[INFO] +- org.springframework.cloud:spring-cloud-starter-gateway:jar:2.0.0.RELEASE:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-starter:jar:2.0.0.RELEASE:compile
[INFO] |  |  +- org.springframework.cloud:spring-cloud-context:jar:2.0.0.RELEASE:compile
[INFO] |  |  |  \- org.springframework.security:spring-security-crypto:jar:5.0.3.RELEASE:compile
[INFO] |  |  +- org.springframework.cloud:spring-cloud-commons:jar:2.0.0.RELEASE:compile
[INFO] |  |  \- org.springframework.security:spring-security-rsa:jar:1.0.5.RELEASE:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-gateway-core:jar:2.0.1.RELEASE:compile
[INFO] |  |  \- io.projectreactor.addons:reactor-extra:jar:3.1.6.RELEASE:compile
[INFO] |  |     \- io.projectreactor:reactor-core:jar:3.1.5.RELEASE:compile
[INFO] |  \- org.springframework.boot:spring-boot-starter-webflux:jar:2.0.0.RELEASE:compile
[INFO] |     +- org.springframework.boot:spring-boot-starter-json:jar:2.0.0.RELEASE:compile
[INFO] |     |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.4:compile
[INFO] |     |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.4:compile
[INFO] |     |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.4:compile
[INFO] |     +- org.springframework.boot:spring-boot-starter-reactor-netty:jar:2.0.0.RELEASE:compile
[INFO] |     |  \- io.projectreactor.ipc:reactor-netty:jar:0.7.5.RELEASE:compile
[INFO] |     |     +- io.netty:netty-codec-http:jar:4.1.22.Final:compile
[INFO] |     |     |  \- io.netty:netty-codec:jar:4.1.22.Final:compile
[INFO] |     |     +- io.netty:netty-handler:jar:4.1.22.Final:compile
[INFO] |     |     |  +- io.netty:netty-buffer:jar:4.1.22.Final:compile
[INFO] |     |     |  \- io.netty:netty-transport:jar:4.1.22.Final:compile
[INFO] |     |     |     \- io.netty:netty-resolver:jar:4.1.22.Final:compile
[INFO] |     |     +- io.netty:netty-handler-proxy:jar:4.1.22.Final:compile
[INFO] |     |     |  \- io.netty:netty-codec-socks:jar:4.1.22.Final:compile
[INFO] |     |     \- io.netty:netty-transport-native-epoll:jar:4.1.22.Final:compile
[INFO] |     |        +- io.netty:netty-common:jar:4.1.22.Final:compile
[INFO] |     |        \- io.netty:netty-transport-native-unix-common:jar:4.1.22.Final:compile
[INFO] |     +- org.hibernate.validator:hibernate-validator:jar:6.0.7.Final:compile
[INFO] |     |  +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] |     |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] |     |  \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] |     +- org.springframework:spring-webflux:jar:5.0.4.RELEASE:compile
[INFO] |     \- org.synchronoss.cloud:nio-multipart-parser:jar:1.1.0:compile
[INFO] |        \- org.synchronoss.cloud:nio-stream-storage:jar:1.1.3:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.0.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.0.0.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.0.RELEASE:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] |  |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.19:runtime
[INFO] |  +- org.springframework:spring-aop:jar:5.0.4.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-beans:jar:5.0.4.RELEASE:compile
[INFO] |  +- org.springframework.security:spring-security-config:jar:5.0.3.RELEASE:compile
[INFO] |  |  +- org.springframework.security:spring-security-core:jar:5.0.3.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-context:jar:5.0.4.RELEASE:compile
[INFO] |  \- org.springframework.security:spring-security-web:jar:5.0.3.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:5.0.4.RELEASE:compile
[INFO] +- org.springframework.cloud:spring-cloud-starter-netflix-hystrix:jar:2.0.0.RELEASE:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-netflix-core:jar:2.0.0.RELEASE:compile
[INFO] |  |  \- org.springframework.boot:spring-boot-starter-aop:jar:2.0.0.RELEASE:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-netflix-ribbon:jar:2.0.0.RELEASE:compile
[INFO] |  |  \- org.springframework.cloud:spring-cloud-netflix-archaius:jar:2.0.0.RELEASE:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-starter-netflix-archaius:jar:2.0.0.RELEASE:compile
[INFO] |  |  +- com.netflix.archaius:archaius-core:jar:0.7.6:compile
[INFO] |  |  |  \- com.google.code.findbugs:jsr305:jar:3.0.1:runtime
[INFO] |  |  \- commons-configuration:commons-configuration:jar:1.8:compile
[INFO] |  |     \- commons-lang:commons-lang:jar:2.6:compile
[INFO] |  +- com.netflix.hystrix:hystrix-core:jar:1.5.12:compile
[INFO] |  |  +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] |  |  +- io.reactivex:rxjava:jar:1.3.6:compile
[INFO] |  |  \- org.hdrhistogram:HdrHistogram:jar:2.1.9:compile
[INFO] |  +- com.netflix.hystrix:hystrix-serialization:jar:1.5.12:compile
[INFO] |  |  +- com.fasterxml.jackson.module:jackson-module-afterburner:jar:2.9.4:runtime
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.4:compile
[INFO] |  +- com.netflix.hystrix:hystrix-metrics-event-stream:jar:1.5.12:compile
[INFO] |  +- com.netflix.hystrix:hystrix-javanica:jar:1.5.12:compile
[INFO] |  |  +- org.apache.commons:commons-lang3:jar:3.7:runtime
[INFO] |  |  +- org.ow2.asm:asm:jar:5.0.4:runtime
[INFO] |  |  +- org.aspectj:aspectjweaver:jar:1.8.13:compile
[INFO] |  |  \- com.google.guava:guava:jar:15.0:compile
[INFO] |  \- io.reactivex:rxjava-reactive-streams:jar:1.2.1:compile
[INFO] |     \- org.reactivestreams:reactive-streams:jar:1.0.2:compile
[INFO] +- org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:jar:2.0.0.RELEASE:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.4:compile
[INFO] |  +- org.springframework.boot:spring-boot:jar:2.0.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.0.RELEASE:compile
[INFO] |  +- org.springframework.security.oauth:spring-security-oauth2:jar:2.2.1.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-webmvc:jar:5.0.4.RELEASE:compile
[INFO] |  |  +- commons-codec:commons-codec:jar:1.11:compile
[INFO] |  |  \- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] |  |     \- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] |  +- org.springframework.security:spring-security-jwt:jar:1.0.9.RELEASE:compile
[INFO] |  |  \- org.bouncycastle:bcpkix-jdk15on:jar:1.56:compile
[INFO] |  |     \- org.bouncycastle:bcprov-jdk15on:jar:1.56:compile
[INFO] |  \- org.springframework:spring-web:jar:5.0.4.RELEASE:compile
[INFO] \- org.springframework.boot:spring-boot-starter-test:jar:2.0.0.RELEASE:test
[INFO]    +- org.springframework.boot:spring-boot-test:jar:2.0.0.RELEASE:test
[INFO]    +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.0.RELEASE:test
[INFO]    +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO]    |  \- net.minidev:json-smart:jar:2.3:test
[INFO]    |     \- net.minidev:accessors-smart:jar:1.2:test
[INFO]    +- junit:junit:jar:4.12:test
[INFO]    +- org.assertj:assertj-core:jar:3.9.1:test
[INFO]    +- org.mockito:mockito-core:jar:2.15.0:test
[INFO]    |  +- net.bytebuddy:byte-buddy:jar:1.7.10:test
[INFO]    |  +- net.bytebuddy:byte-buddy-agent:jar:1.7.10:test
[INFO]    |  \- org.objenesis:objenesis:jar:2.6:test
[INFO]    +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO]    +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO]    +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO]    |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO]    +- org.springframework:spring-core:jar:5.0.4.RELEASE:compile
[INFO]    |  \- org.springframework:spring-jcl:jar:5.0.4.RELEASE:compile
[INFO]    +- org.springframework:spring-test:jar:5.0.4.RELEASE:test
[INFO]    \- org.xmlunit:xmlunit-core:jar:2.5.1:test

1 个答案:

答案 0 :(得分:1)

在处理阶段不会发生此错误,而是在响应的实际流处理期间发生。这是一个很低的级别,WebExceptionHandler合同未涵盖。

您似乎正在使用Spring Framework 5.0.x,在此版本中,此异常记录在WARN级别as of 5.0.6 and #21229上。在Spring Framework 5.1.x,significant changes have been made to the logging experience中,这些日志现在处于TRACE级别,因此您不再应该默认看到这些日志。

同时,您可以调整ReactorHttpHandlerAdapter类的日志记录级别,并且仅考虑ERROR级别的日志。