为什么java.util.logging.Logger打印到stderr? [英] Why does java.util.logging.Logger print to stderr?
问题描述
我有一个简单的设置来记录一条消息:JDK 8 Update 65
和Eclipse Mars
import java.util.logging.Logger;
public class Example {
private final static Logger LOGGER = Logger.getLogger(Example.class.getName());
public static void main(String[] args) {
LOGGER.info("Test");
}
}
我希望在stdout
上获得输出,就像使用System.out.println();
一样.
但是却将其打印在stderr
上,这在Eclipse控制台上显示为红色字体:
我知道我可以通过编写自定义的Handler
来更改此行为,但是我想知道为什么默认输出出现在stderr
而不是stdout
上吗?
记录器应将stdout
用于fine
+ info
,并将stderr
用于severe
级别.
默认情况下,记录器将INFO或更高级别的日志记录(即INFO,WARNING和SEVERE)输出到标准错误流(System.err). /p>
来源: www3.ntu.edu.sg/home/ehchua/programming/java/JavaLogging.html
I've got a simple setup to log a message: JDK 8 Update 65
and Eclipse Mars
import java.util.logging.Logger;
public class Example {
private final static Logger LOGGER = Logger.getLogger(Example.class.getName());
public static void main(String[] args) {
LOGGER.info("Test");
}
}
I would expect to get an output on the stdout
, just like using System.out.println();
.
But instead it gets printed out on the stderr
, which results in a red font on the eclipse console:
I know that I can change this behavior by writing a custom Handler
, but I wish to know why the default output appears on the stderr
instead of stdout
?
A logger should use stdout
for fine
+info
and use stderr
for severe
level.
By default, the logger outputs log records of level INFO and above (i.e., INFO, WARNING and SEVERE) to standard error stream (System.err).
Source: www3.ntu.edu.sg/home/ehchua/programming/java/JavaLogging.html
这篇关于为什么java.util.logging.Logger打印到stderr?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!