SpringBoot2.0 项目异常日志,但不影响运行

Posted 一线大码

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SpringBoot2.0 项目异常日志,但不影响运行相关的知识,希望对你有一定的参考价值。

第一段:

2019-04-16 21:05:22 [WARN] [org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver:197] - Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not parse ‘Accept‘ header [/]: Invalid mime type "/": does not contain subtype after ‘/‘]
2019-04-16 21:19:13 [WARN] [org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver:197] - Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not parse ‘Accept‘ header [/]: Invalid mime type "/": does not contain subtype after ‘/‘]
2019-04-17 01:46:33 [INFO] [org.apache.juli.logging.DirectJDKLog:175] - Error parsing HTTP request header
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
	at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:414)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:294)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
2019-04-17 02:49:43 [WARN] [org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver:197] - Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not parse ‘Accept‘ header [/]: Invalid mime type "/": does not contain subtype after ‘/‘]

第二段:

2019-04-18 02:08:43 [INFO] [org.apache.juli.logging.DirectJDKLog:175] - Error parsing HTTP request header
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
	at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:467)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:294)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
2019-04-18 02:44:42 [WARN] [org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver:197] - Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not parse ‘Accept‘ header [/]: Invalid mime type "/": does not contain subtype after ‘/‘]
2019-04-18 02:47:57 [WARN] [org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver:197] - Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not parse ‘Accept‘ header [/]: Invalid mime type "/": does not contain subtype after ‘/‘]
2019-04-18 05:26:21 [WARN] [org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver:197] - Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not parse ‘Accept‘ header [/]: Invalid mime type "/": does not contain subtype after ‘/‘]

看下网上的解决方案:

(1)原因是Tomcat的header缓冲区大小不够,只需要在 server.xml 中增加 maxHttpHeaderSize 字段即可:

<Connector connectionTimeout="20000" maxHttpHeaderSize="10000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

我是在 SpringBoot 中的配置文件添加了:

server.max-http-header-size=16KB

(2)头部包含了特殊字符的原因:

Tomcat 7.0.81以上支持,打开conf/catalina.properties在底部将

#tomcat.util.http.parser.HttpParser.requestTargetAllow=|

修改为

tomcat.util.http.parser.HttpParser.requestTargetAllow=|,{,}

 

以上是关于SpringBoot2.0 项目异常日志,但不影响运行的主要内容,如果未能解决你的问题,请参考以下文章

springboot2.0整合logback日志(详细)

Spring boot2.0 + Vue脚手架项目源码,中小型管理系统开发神器。

Spring boot2.0 + Vue脚手架项目源码,中小型管理系统开发神器。

SpringBoot2.0 基础案例(02):配置Log4j2,实现不同环境日志打印

SpringBoot2.0 基础案例(02):配置Log4j2,实现不同环境日志打印

SpringBoot2.0 基础案例(02):配置Log4j2,实现不同环境日志打印