我正在运行一个Jboss服务器,其中包括一个JAX-RS Web服务(使用与Jboss / EAP捆绑的resteasy-2.3.6.Final).
当客户端中止对服务器的调用时,Resteasy Synchronousdispatcher可以(显然)不会将响应发送回客户端,这会导致在[SEVERE]和[ERROR]级别的一系列错误显示在我的服务器日志中.
但是,我不认为这些是实际的错误,所以我不想看到它们.特别是一旦这项服务公开使用,这一定会经常发生.
这是我要抑制的日志输出:
12:50:38,938 SEVERE [org.jboss.resteasy.core.Synchronousdispatcher] (http-localhost/127.0.0.1:8080-2) Failed executing GET /ajax/findPerson: org.jboss.resteasy.spi.WriterException: ClientAbortException: java.net.socketException: broken pipe at org.jboss.resteasy.core.ServerResponse.writeto(ServerResponse.java:262) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1] .... Caused by: ClientAbortException: java.net.socketException: broken pipe at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:403) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1] at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:356) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1] at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:426) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1] at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:415) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1] ... Caused by: java.net.socketException: broken pipe at java.net.socketoutputStream.socketWrite0(Native Method) [rt.jar:1.7.0_51] at java.net.socketoutputStream.socketWrite(SocketoutputStream.java:113) [rt.jar:1.7.0_51] at java.net.socketoutputStream.write(SocketoutputStream.java:159) [rt.jar:1.7.0_51] at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:711) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1] at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:450) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1] at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:351) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1] ... 12:50:38,942 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/myapplication].[MyAjaxApplication]] (http-localhost/127.0.0.1:8080-2) JBWEB000236: Servlet.service() for servlet MyAjaxApplication threw exception: java.lang.IllegalStateException at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:392) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1] at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:152) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1] ...
有没有一个优雅的方法呢?
通过writing my own ExceptionMapper我设法防止了第一个(SEVERE),并将其转换为调试级别的单行日志输出,但第二个仍然存在.坦白说,我不知道哪里甚至开始寻找.
我在另一个SO问题中看到I could just set the log level for one or both classes that throw the errors to a higher level,说[FATAL],但我会考虑这个更多的解决方法…
想法?
在JBoss standalone.xml配置文件中,转到记录子系统(例如通过搜索)
< subsystem xmlns =“urn:jboss:domain:logging:1.5”>如果您使用EAP 6.4.0),然后为要抑制错误的类别添加记录器.对于你的例子,如果你想抑制org.jboss.resteasy的日志,那么你的记录器就像
< subsystem xmlns =“urn:jboss:domain:logging:1.5”>如果您使用EAP 6.4.0),然后为要抑制错误的类别添加记录器.对于你的例子,如果你想抑制org.jboss.resteasy的日志,那么你的记录器就像
<logger category="org.jboss.resteasy"> <level name="OFF"/> </logger>
将级别设置为OFF可以抑制记录器记录包org.jboss.resteasy中的错误