Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuration Log4j: ConsoleAppender to System.err?

Tags:

console

log4j

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 console, 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?

like image 462
Gerard Avatar asked Feb 01 '26 04:02

Gerard


1 Answers

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.

like image 65
Péter Török Avatar answered Feb 03 '26 22:02

Péter Török



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!