如何将控制台中的输出记录到文件中? [英] How to logging output in console to file?

查看:1072
本文介绍了如何将控制台中的输出记录到文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NetBeans生成代码,如 Logger.getLogger(svr.class.getName())。log(Level.SEVERE,null,ex); 以在catch中输出异常它将显示在控制台中。
我部署项目后,我看不到任何异常信息。如何在控制台可用时将这些错误消息输出到文件和控制台?

The NetBeans generate code like Logger.getLogger(svr.class.getName()).log(Level.SEVERE, null, ex); to output exception in catch.It will display in console. After I deploy my project,I cannot see any exception info.How to output those error messages to file and in console when console is available?

谢谢大家。

推荐答案

NetBeans中的日志记录系统基于标准JDK的java.util.logging并尽可能地遵守它。为了将错误消息输出到文件,您可以在项目的类路径上提供自己的日志记录属性文件。

The logging system in NetBeans is based on the standard JDK's java.util.logging and complies to it as much as possible. In order to output error messages to a file, you can provide your own logging properties file on the classpath of your project.

有关详细信息,请参阅以下链接:

See the following links for more info :

使用日志属性文件示例的Java Util日志记录示例:
http://www.javapractices.com/topic/TopicAction.do?Id=143

Java Util logging with logging properties file sample : http://www.javapractices.com/topic/TopicAction.do?Id=143

这篇关于如何将控制台中的输出记录到文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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