Filter unwanted INFO-Messages from Logger
I'm using java.util.logging
to log in my Java application. I'm also using javax.xml.ws.Endpoint
to publish a SOAP-interface.
Over the time I added more and more exceptions which all turn up at startup with a log-entry like this:
Jan 24, 2011 12:29:27 PM com.sun.xml.internal.ws.model.RuntimeModeler getExceptionBeanClass
INFO: Dynamically creating exception bean Class de.wi08e.myhome.frontend.jaxws.NotLoggedInBean
I tried following filter to block them, but I'm not sure which cl开发者_如何学Goass to get with getLogger
:
/* Filter ExceptionBeanClass logs */
Logger loggerInfo = Logger.getLogger("javax.xml.ws.Endpoint");
loggerInfo.setFilter(new Filter() {
@Override
public boolean isLoggable(LogRecord l) {
System.out.println(l.getMessage());
if (l.getMessage().startsWith("Dynamically creating exception bean Class"))
return false;
return true;
}
});
Does anyone know how to find out which class creates this log-entries? Is there another way to filter out this nerving messages?
EDIT: I also tried Logger.getLogger("com.sun.xml.internal.ws.model.RuntimeModeler")
, but it's still not working...
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.
精彩评论