SLF4J: Failed toString() invocation on an object of type [org.eclipse.jetty.websocket.server......

在配置SpringBoot的log时,遇到如下错误:

SLF4J: Failed toString() invocation on an object of type [org.eclipse.jetty.websocket.server.WebSocketServerFactory]
Reported exception:
java.lang.NullPointerException
	at org.eclipse.jetty.websocket.server.WebSocketServerFactory.toString(WebSocketServerFactory.java:641)
	at org.slf4j.helpers.MessageFormatter.safeObjectAppend(MessageFormatter.java:299)
	at org.slf4j.helpers.MessageFormatter.deeplyAppendParameter(MessageFormatter.java:271)
	at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:233)
	at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:173)
	at org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:619)
	at org.eclipse.jetty.util.log.JettyAwareLogger.debug(JettyAwareLogger.java:206)
	at org.eclipse.jetty.util.log.Slf4jLog.debug(Slf4jLog.java:89)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:322)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:226)
	at org.eclipse.jetty.websocket.server.WebSocketServerFactory.(WebSocketServerFactory.java:149)
	at org.eclipse.jetty.websocket.server.WebSocketServerFactory.(WebSocketServerFactory.java:126)
	at org.eclipse.jetty.websocket.server.WebSocketServerFactory.(WebSocketServerFactory.java:105)
	at org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration.(NativeWebSocketConfiguration.java:51)
	at org.eclipse.jetty.websocket.server.NativeWebSocketServletContainerInitializer.getDefaultFrom(NativeWebSocketServletContainerInitializer.java:36)
	at org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer.configureContext(WebSocketServerContainerInitializer.java:139)
	at org.springframework.boot.autoconfigure.websocket.JettyWebSocketContainerCustomizer$1.configure(JettyWebSocketContainerCustomizer.java:45)
	at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:517)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1458)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785)
	at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
	at org.eclipse.jetty.server.Server.start(Server.java:452)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
	at org.eclipse.jetty.server.Server.doStart(Server.java:419)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer.initialize(JettyEmbeddedServletContainer.java:104)
	at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer.(JettyEmbeddedServletContainer.java:82)
	at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory.getJettyEmbeddedServletContainer(JettyEmbeddedServletContainerFactory.java:561)
	at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory.getEmbeddedServletContainer(JettyEmbeddedServletContainerFactory.java:190)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
	at com.baidu.hetu.Application.main(Application.java:17)

查了很多资料,应该是jetty的一个bug,jetty版本jetty-9.4.6.v20170531。
https://stackoverflow.com/questions/26416072/slf4j-failed-tostring-invocation-on-an-object-of-type-com-datastax-driver-co
原因还不是特别清楚,但是通过错误能够看出来与SLF4J有关,而且通过查资料能够看出和日志级别有关,原logback.xml 如下



    
        
            %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg\n
        

        
            INFO
        
    

    
        
    

改为可解决上面问题。具体原因有待验证。

你可能感兴趣的:(web,SpringBoot,SLF4J,Log)