Redirect output logs of javax.xml.ws and com.sun.xml.ws
- by chrisnfoneur
I am working on a SOAP based web service, with Sun's Metro.
I am facing an annoying bug, each time I send a malformed SOAP object to my web service, sun's api spam the System.out with logs like this: 
  javax.xml.ws.WebServiceException: com.sun.istack.XMLStreamException2: org.xml.sax.SAXParseException: cvc-complex-type.4: Attribute 'type' must appear on element 'object'.
      at com.sun.xml.ws.util.pipe.AbstractSchemaValidationTube.doProcess(AbstractSchemaValidationTube.java:206)
      at com.sun.xml.ws.util.pipe.AbstractSchemaValidationTube.processRequest(AbstractSchemaValidationTube.java:175)
      at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
      at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
      at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
      at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
      at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)
      at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444)
      at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
      at com.sun.xml.ws.transport.http.server.WSHttpHandler.handleExchange(WSHttpHandler.java:106)
      at com.sun.xml.ws.transport.http.server.WSHttpHandler.handle(WSHttpHandler.java:91)
      at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
      at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:54)
      at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:68)
      at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:555)
      at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
      at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:527)
      at sun.net.httpserver.ServerImpl$DefaultExecutor.execute(ServerImpl.java:119)
      at sun.net.httpserver.ServerImpl$Dispatcher.handle(ServerImpl.java:349)
      at sun.net.httpserver.ServerImpl$Dispatcher.run(ServerImpl.java:321)
      at java.lang.Thread.run(Thread.java:619)
  Caused by: com.sun.istack.XMLStreamException2: org.xml.sax.SAXParseException: cvc-complex-type.4: Attribute 'type' must appear on element 'object'.
      at com.sun.xml.ws.util.xml.StAXSource$1.parse(StAXSource.java:185)
      at com.sun.xml.ws.util.xml.StAXSource$1.parse(StAXSource.java:170)
      at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.validate(Unknown Source)
      at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
      at javax.xml.validation.Validator.validate(Validator.java:127)
      at com.sun.xml.ws.util.pipe.AbstractSchemaValidationTube.doProcess(AbstractSchemaValidationTube.java:204)
      ... 20 more
I would like to switch off this log or redirect it to my error/warn/debug.log files used by log4j.
I tried to add a rule in my log4j.xml file :
<category name="javax.xml.ws">
 <priority value="error" />
</category>
It didn't worked.
So I tried the following trick: 
java.util.logging.Logger.getLogger("javax.xml.ws.WebServiceException").setLevel(
            java.util.logging.Level.OFF);
it didn't worked neither.
Any ideas ?
It is not a big issue but it makes my catalina.log getting bigger & bigger and it's not the appropriate place for this kind of log.
Chris