为什么java.util.logging.Logger打印到stderr? [英] Why does java.util.logging.Logger print to stderr?

查看:150
本文介绍了为什么java.util.logging.Logger打印到stderr?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的设置来记录一条消息:JDK 8 Update 65Eclipse 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屋!

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