tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 18462] - System.err gets overriden to output to System.out
Date Thu, 24 Apr 2003 11:22:46 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18462>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18462

System.err gets overriden to output to System.out





------- Additional Comments From andrew.chapman@clicktools.com  2003-04-24 11:22 -------
Okay points taken and understood.

Alternatively what I would like to propose is adding an optional attribute to 
the <Server> tag in server.xml. The attribute will be named "noRedirect" and 
will take a boolean value. So the whole tag would look like:

server.xml
...
<Server port="8005" shutdown="SHUTDOWN" debug="0" noRedirect="true">
...

If no attribute is set then the default is false (current behaviour). Setting 
the attribute to "true" (as above) will mean that System.out and System.err are 
NOT redirected.

Summary of changes:

org.apache.catalina.Server
--------------------------
ADD public void setNoRedirect(boolean noRedirect);
ADD public boolean getNoRedirect();

org.apache.catalina.core.StandardServer
---------------------------------------
ADD private boolean noRedirect = false;
ADD public void setNoRedirect(boolean noRedirect) {...}
ADD public boolean getNoRedirect() {...}

org.apache.catalina.startup.Catalina
------------------------------------
CHANGE protected void start() {...

<<        // Replace System.out and System.err with a custom PrintStream
<<        SystemLogHandler log = new SystemLogHandler(System.out);
<<        System.setOut(log);
<<        System.setErr(log);

>>        // Replace System.out and System.err with a custom PrintStream if the
>>        // noRedirect switch is false (default)
>>        if (server.getNoRedirect() == false) {
>>          SystemLogHandler log = new SystemLogHandler(System.out);
>>          System.setOut(log);
>>          System.setErr(log);
>>        }

...}

This involves changing the Server interface however, which is not to be taken 
lightly. An alternative may be to leave the interface and just add the 
noRedirect to StandardServer (as debug is currently), then check the server 
class as follows:

>>        // Replace System.out and System.err with a custom PrintStream if the
>>        // using StandardServer and noRedirect switch is false (default)
>>        if (server instanceof StandardServer) {
>>          if (server.getNoRedirect() == false) {
>>            SystemLogHandler log = new SystemLogHandler(System.out);
>>            System.setOut(log);
>>            System.setErr(log);
>>          }
>>        } else {
>>          SystemLogHandler log = new SystemLogHandler(System.out);
>>          System.setOut(log);
>>          System.setErr(log);
>>        }

I think the change to Server is the most contentious aspect of this proposal. I 
have a patch for the former implementation (with changes to Server). This is 
neater in some respects adding this functionality to all Server 
implementations, but obviously "breaking" any existing implementations other 
than StandardServer.

I'll await comment and if acceptable I'll submit a patch.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message