从记录器中过滤不需要的信息消息

发布于 2024-10-14 03:07:29 字数 966 浏览 7 评论 0原文

我正在使用 java.util.logging 登录我的 Java 应用程序。我还使用 javax.xml.ws.Endpoint 来发布 SOAP 接口。

随着时间的推移,我添加了越来越多的异常,这些异常在启动时都会出现这样的日志条目:

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

我尝试使用以下过滤器来阻止它们,但我不确定使用 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;
    }

});

有谁知道如何找出哪个类创建了这个日志条目?有没有其他方法可以过滤掉这些令人紧张的信息?

编辑:我也尝试了 Logger.getLogger("com.sun.xml.internal.ws.model.RuntimeModeler"),但它仍然不起作用......

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 class 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...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

玩世 2024-10-21 03:07:29

您应该能够使用以下标志运行 java 程序: -Djava.util.logging.config.file= 其中 mylogging.properties 是具有以下内容的文件而不是用代码来做。

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

来自 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");

和常量

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

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";
梦归所梦 2024-10-21 03:07:29

编辑: Clement P 早在我之前就回答了这个问题;所有的人都应该为他竖起大拇指!

我将我的答案保留在这里,因为它使用了稍微不同的方式。


我现在已经自己解决了。简而言之,这就是解决方案:

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

如果有人感兴趣,这就是我找到它的方法:

com.sun.xml.internal.ws.model.RuntimeModeler 负责对于消息。它使用静态Logger,并通过

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

Google-ing函数实例化com.sun.xml.ws.util.Constants引导此处,您可以在其中复制并粘贴 LoggingDomain 常量。

但请记住:该解决方案并不适用于所有 JRE,因为它依赖于 Sun 的“私有”命名空间和实现。

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.

沫尐诺 2024-10-21 03:07:29

日志条目似乎表明是 com.sun.xml.internal.ws.model.RuntimeModeler 类生成了此日志消息。您应该能够通过提高此记录器的级别来过滤它。

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.

泅人 2024-10-21 03:07:29

或者,您可以只创建缺少的类。
实际上,这是我创建 Web 服务时遵循的标准流程。

如果您创建此类(即de.wi08e.myhome.frontend.jaxws.NotLoggedInBean),
那么它将只使用现有的类,而不会尝试在运行时创建它。

实际上,您甚至不必自己创建这些类。您可以使用 wsgen 工具生成它们。 wsgen.exe 是 java jdk 的一部分。因此,您可以从命令行运行它。

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

接下来将创建的文件移动到正确的项目源文件夹。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文