Log4j configuration: ConsoleAppender for System.err?

I saw one of our tools use ConsoleAppender for System.err next to System.out in the log4j configuration. Configuration Fragments:

<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 leads to double messages to the console, so I find this to be useless, right? On a Linux server, I see only one message for the PuTTY console, so where would this System.err message go?

+3
source share
1 answer

This can be useful depending on how standard errors are redirected. Often the standard output is disabled (for example, redirected to / dev / null), so error output is the only way to display error messages.

, PuTTY - stderr, stdout. , CONSOLE_ERR ERROR WARN. PuTTY, , , .

+2

Source: https://habr.com/ru/post/1739437/


All Articles