DO NOT REPLY [Bug 18462] System.err gets overriden to output to System.out

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

DO NOT REPLY [Bug 18462] System.err gets overriden to output to System.out

Bugzilla from

Konstantin Kolinko <[hidden email]> changed:

           What    |Removed                     |Added
          Component|Catalina                    |Catalina
            Version|4.1.24                      |trunk
            Product|Tomcat 4                    |Tomcat 7

--- Comment #12 from Konstantin Kolinko <[hidden email]> 2011-01-10 18:39:36 EST ---
Moving from Tomcat 4/4.1.24 to Tomcat 7.

My concern is when Tomcat is installed on Windows: it is by default configured
to log err and out to separate files.

Steps to reproduce:
1. Install apache-tomcat-6.0.30.exe with the Examples webapp.
2. Launch Tomcat and navigate to
3. Look into logs/tomcat6-stdout.2011-01-10.log
Actual result: The file contains the following:
2011-01-10 23:33:27 Commons Daemon procrun stdout initialized
Did you see me on the stderr window?

Did you see me on the browser window as well?
Expected result: The "Did you see me on the stderr window?" message should have
been printed into *stderr* log, not in *stdout* log.

At the same time the tomcat6-stderr.2011-01-10.log file contains a lot of text,
printed by the logging subsystem. It is java.util.logging.ConsoleHandler that
prints there.

As was noticed earlier, the culprit is Embedded#initStreams() (TC5.5,6,7) and
Catalina#initStreams() (TC7).
>>  // Replace System.out and System.err with a custom PrintStream
>>  SystemLogHandler systemlog = new SystemLogHandler(System.out);
>>  System.setOut(systemlog);
>>  System.setErr(systemlog);

Initialization of JULI happens before this redirection, and thus
java.util.logging.ConsoleHandler prints to the original System.err.

My thoughts of this:
1) SystemLogHandler can be enhanced to support separate out and err streams.
2) If we do not fix this, then maybe configure commons-daemon to log both
streams to the same file by default.
It is done by setting Stderr name in its configuration to be an empty string.
-- See method redirectStdStreams() in prunsrv.c.
3) It is worth being mentioned in the FAQ.
4) This feature is not needed at all if no Context is configured with
"swallowOutput=true". So maybe make it configurable and turn it off by default.
The name for the configuration property might be "redirectStreams", like it is
already used as the field name Embedded#redirectStreams.

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]