如何在java中禁用运行时警告? [英] How to disable runtime warnings in java?

查看:477
本文介绍了如何在java中禁用运行时警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在java程序中使用jar文件,它在运行时生成警告。但我不希望我的客户看到这些警告。
如何禁用这些警告。

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.

警告如下:

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


推荐答案

从消息的外观来看,您正在使用< a href =http://htmlunit.sourceforge.net/logging.html =nofollow noreferrer> HtmlUnit,它使用Commons Logging 来记录消息。除非您将Commons Logging配置为写入文件,否则日志消息将由Commons Logging的简单记录器记录,该记录将写入控制台。

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:


  1. 配置Commons Logging写入a磁盘上的文件(使用log4j)。

  2. 将控制台输出重定向到/ dev / null或其等效项,如同精确定位。

这篇关于如何在java中禁用运行时警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆