我在使用 java.util.logging.Logger 这个东西的时候发现在输出日志时在命令行显示的是红色的文字 . 例如:
2009-2-18 16:13:24 cn.iamsese.product.custom.reflect.common.ReflectConsole log
信息: 日志测试
请问在命令行输出这种带颜色的字符串,是怎么做到的啊??
google找到的:
[b][color=red]the default console handler of java.util.logging prints messages
to System.err, and therefor Eclipse renders them red[/color][/b].
你可以通过修改eclipse里的console配色(当然这也影响了其他标准err输出的颜色),或者就是扩展ConsoleHandler :
[code="java"]class myConsoleHandler extends ConsoleHandler {
public myConsoleHandler() {
super();
this.setOutputStream(System.out);
}
}[/code]
更可取的方法是直接使用log4j,可配置的
你是指Eclipse吗,可以设置console的属性来改变颜色的。
当然,如果你的意思是可以在程序里控制输出颜色的话,我觉得应该是不能