【发布时间】:2017-03-24 09:43:59
【问题描述】:
我正在使用 htmlunit [http://htmlunit.sourceforge.net/],它会发出一堆警告/错误:
2017 年 3 月 24 日下午 6:37:30 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl 通知 警告:遇到过时的内容类型:'text/javascript'。 2017 年 3 月 24 日下午 6:37:31 com.gargoylesoftware.htmlunit.html.InputElementFactory createElementNS 信息:错误的输入类型:“日期时间”,创建文本输入 2017 年 3 月 24 日下午 6:37:31 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl 通知 警告:遇到过时的内容类型:'application/x-javascript'。 2017 年 3 月 24 日下午 6:37:32 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl 通知 警告:遇到过时的内容类型:'application/x-javascript'。 2017 年 3 月 24 日下午 6:37:34 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl 通知 警告:遇到过时的内容类型:'text/javascript'。 2017 年 3 月 24 日下午 6:37:34 com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError 严重:runtimeError:消息=[指定了无效或非法的选择器(选择器:'*,:x'错误:无效的选择器::x)。] sourceName=[https://www.example.com/bundles/jquery?v=u8J3xxyrazUhSJl-OWRJ6I82HpC6Fs7PQ0-l8XzoZXY1] line=[1] lineSource=[null] lineOffset =[0] 2017 年 3 月 24 日下午 6:37:35 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl 通知 警告:遇到过时的内容类型:'text/javascript'。 2017 年 3 月 24 日下午 6:37:35 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl 通知 警告:遇到过时的内容类型:'text/javascript'。 2017 年 3 月 24 日下午 6:37:35 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl 通知 警告:遇到过时的内容类型:'text/javascript'。 2017 年 3 月 24 日下午 6:37:36 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl 通知 警告:遇到过时的内容类型:'text/javascript'。 2017 年 3 月 24 日下午 6:37:43 com.gargoylesoftware.htmlunit.javascript.host.dom.Document createElement 信息:createElement:提供字符串 'iframe name="rufous-frame-29_-1">https://platform.twitter.com/widgets.js] line=[9] lineSource=[null] lineOffset=[0]
我查看了其他资源并尝试通过以下方式将其关闭:
Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
Logger.getLogger("org.apache.http").setLevel(Level.OFF);
和:
final WebClient webClient = new WebClient(BrowserVersion.EDGE);
但它不起作用。
还有什么方法可以抑制这些警告/错误消息?
【问题讨论】:
-
确保在调用 HtmlUnit 之前设置记录器。如果没有,请发布您的完整代码
-
谢谢,我把代码和另一行(见我的回答)和错误/sarnings停止出现。
标签: java logging htmlunit java.util.logging