Filter unwanted INFO-Messages from Logger

孤人 提交于 2019-12-01 11:08:25

You should be able to just run the java program with the following flag: -Djava.util.logging.config.file=<mylogging.properties> where mylogging.properties is a file with the following contents instead of doing it in code.

javax.enterprise.resource.webservices.jaxws.server.level = WARN

From http://www.docjar.com/html/api/com/sun/xml/internal/ws/model/RuntimeModeler.java.html

  186       private static final Logger logger =
  187           Logger.getLogger(
  188               com.sun.xml.internal.ws.util.Constants.LoggingDomain + ".server");

and from Constants

  public static final java.lang.String LoggingDomain = "javax.enterprise.resource.webservices.jaxws";

Edit: Clement P answered this question right long before me; all thumbs-up should go to him!

I keep my answer here because it uses a slightly other way.


I've now solved it myself. In short, this is the solution:

Logger.getLogger("javax.enterprise.resource.webservices.jaxws.server").setLevel(Level.WARNING);

If anyone's interested, this is how I found it:

The method getExceptionBeanClass in com.sun.xml.internal.ws.model.RuntimeModeler is responsible for the messages. It uses a static Logger instanciated with the function

Logger.getLogger(com.sun.xml.ws.util.Constants.LoggingDomain + ".server");

Google-ing for com.sun.xml.ws.util.Constants leads here where you can copy-and-past the LoggingDomain constant.

But keep in mind: This solution won't work on every JRE, because it depends on Sun's 'private' namespace and implementation.

The log entry seems to indicate that it's the com.sun.xml.internal.ws.model.RuntimeModeler class which generates this log message. You should be able to filter it out by raisong the level for this logger.

Alternatively, you could just create the missing class. Actually, that's the standard procedure that I follow when creating webservices.

If you create this class (i.e. de.wi08e.myhome.frontend.jaxws.NotLoggedInBean), then it will just use the existing class, without trying to create it at runtime.

Actually, you don't even have to create these classes yourself. You can generate them using the wsgen tool. The wsgen.exe is part of the java jdk. So, you can just run this from the commandline.

wsgen.exe -verbose -keep -cp . de.wi08e.myhome.frontend.WebService -d source

Next move the created files to the correct project source folder.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!