开发者

Configuration Log4j: ConsoleAppender to System.err?

开发者 https://www.devze.com 2022-12-25 02:38 出处:网络
I saw that one of our tools uses a ConsoleAppender to System.err next to System.out in it\'s log4j configuration. Fragments of the configuration:

I saw that one of our tools uses a ConsoleAppender to System.err next to System.out in it's log4j configuration. Fragments of the configuration:

<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
        <!-- Log to STDOUT. -->
        <param name="Target" value="System.out"/>

....

<appender name="CONSOLE_ERR" class="org.apache.log4j.ConsoleAppender">
            <!-- Log to STDERR. -->
    <param name="Target" value="System.err"/>

In Eclipse this results in double messages to the con开发者_运维百科sole, so I believe that is of no use, right? On the Linux server I see only one message to the PuTTY console, so where would that System.err message go to?


It can be of use depending on how the standard and error outputs are redirected. Often the standard output is muted (e.g. redirected to /dev/null) so the error output is the only way to actually display error messages.

I suspect that PuTTY actually does that - it would be very unusual to mute stderr but not stdout. I guess that your CONSOLE_ERR is set to ERROR or WARN level. In this case, you could check with PuTTY whether only error messages are displayed or all of them, to decide which appender's output you are actually seeing.

0

精彩评论

暂无评论...
验证码 换一张
取 消