java禁止,如何在java中禁用运行时警告?

这篇博客讨论了在使用HtmlUnit库时遇到的关于JavaScript元素类型不匹配的警告问题。作者指出,这些警告是由于 Commons Logging 默认将消息输出到控制台导致的。为了解决这个问题,提供了两种解决方案:配置Commons Logging将日志写入文件,或者将控制台输出重定向到/dev/null。这两种方法可以帮助开发者隐藏运行时的警告信息,提升用户体验。
摘要由CSDN通过智能技术生成

I am using a jar file in a java program and it generates warnings during runtime. But I don't want that my customer sees these warnings.

How can I disable these warnings.

The warning is as below:

Sep 25, 2009 10:10:33 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify

WARNING: Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'http://www.craigslist.org/js/jquery.js', but got 'application/x-javascript'.

解决方案

From the appearance of the message, you are using HtmlUnit which uses Commons Logging for logging messages. Unless you configure Commons Logging to write to a file, the log messages will get logged by the simple logger of Commons Logging which writes out onto the console.

If you want to make the error messages go away you could adopt either of the options:

Configure Commons Logging to write to a file on disk (using log4j).

Redirect the console output to /dev/null or its equivalent, as sal pinpointed.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值