I'm running a Jboss server with, among other things, a JAX-RS Web service (using the resteasy-2.3.6.Final bundled with Jboss / EAP).
When a client aborts a call to the server, the Resteasy SynchronousDispatcher
can (obviously) not send the response back to the client which causes a bunch of errors at the [SEVERE]
and [ERROR]
level to show up in my server logs.
However, I don't consider these as actual errors, so I don't want to see them. Particularly as this is bound to happen often once the service will be in public use.
Here is the log output I want to suppress:
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]
...
Is there an elegant way to do that?
By writing my own ExceptionMapper
I managed to prevent the first one (the [SEVERE]
) and turn it into a debug-level one-line log output, but the second one is still there. Frankly, I have no idea where to even start looking.
I've seen in another SO question that I could just set the log level for one or both classes that throw the errors to a higher level, say [FATAL]
, but I'd consider this more of a workaround...
Ideas?
In the JBoss standalone.xml configuration file, go to the logging subsystem (e.g by searching for
<subsystem xmlns="urn:jboss:domain:logging:1.5">
if you are using EAP 6.4.0), and then add a logger for the category for which you want to suppress the errors. For your example if you want to suppress the logs for org.jboss.resteasy then your logger would look like
<logger category="org.jboss.resteasy">
<level name="OFF"/>
</logger>
Setting the level to OFF should suppress the logger from logging the errors in the package org.jboss.resteasy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With