You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "William L. Thomson Jr." <wl...@gentoo.org> on 2007/11/28 03:44:31 UTC

Bootstrap redirecting stdout/err via system.set

Recently on Gentoo I was looking to improve how we start Tomcat.
Specifically how we capture stdout/stderr output from Tomcat on start
and redirect it to catalina.out. Presently due to our use of
start-stop-daemon and some issues it comes with. We are using the normal
redirection to capture the output. >> catalina.out 2>&1

In getting feedback to alternatives to our present approach, like that
suggested in comment #5 on the following bug[1]. Another inquired as to
why Tomcat wasn't capturing and redirecting it's own stdout/stderr via
system properties?

Like how .home and .base are set now.

public void setCatalinaHome(String s) {
	System.setProperty( "catalina.home", s );
}
public void setCatalinaBase(String s) {
	System.setProperty( "catalina.base", s );
}

Which would alleviate the need to capture and redirect that stuff
externally of Tomcat. Is there a reason this is not currently done? Has
this approach been considered before? Something like 

System.setOut(aPrintStream);
System.setErr(aPrintStream);

Where the location would be configurable via a var or etc with a default
specified.

Basically others are suggesting I write a wrapper class or etc to
Bootstrap to set those properties there. I guess we could do that on
Gentoo. But would like to get upstreams input there. Much less I would
likely patch Bootstrap before wrapping it.


http://bugs.gentoo.org/show_bug.cgi?id=162379

-- 
William L. Thomson Jr.
Gentoo/Java

Re: Bootstrap redirecting stdout/err via system.set

Posted by "William L. Thomson Jr." <wl...@gentoo.org>.
On Wed, 2007-11-28 at 09:47 -0500, William L. Thomson Jr. wrote:
> On Wed, 2007-11-28 at 09:29 +0100, jean-frederic clere wrote:
> > William L. Thomson Jr. wrote:
> > > Recently on Gentoo I was looking to improve how we start Tomcat.
> > > Specifically how we capture stdout/stderr output from Tomcat on start
> > > and redirect it to catalina.out.
> > 
> > Have to tried to use jsvc from http://commons.apache.org/daemon/ for that?
> 
> We presently use start-stop-daemon. Which has some --stdout --stderr
> options coming. It nastily send that stuff to /dev/null, if the
> --background flag is passed along.
> 
> We had a long time bug/feature request for jsvc. I considered it, but
> elected to not go that route.

Forgot link to bug :)

http://bugs.gentoo.org/show_bug.cgi?id=75224


-- 
William L. Thomson Jr.
Gentoo/Java

Re: Bootstrap redirecting stdout/err via system.set

Posted by "William L. Thomson Jr." <wl...@gentoo.org>.
On Wed, 2007-11-28 at 18:28 +0100, jean-frederic clere wrote:
> William L. Thomson Jr. wrote:
> >
> > But I believe the argument is that applications should do their own
> > stderr/out redirection and not to it external of the app. As in not via
> > bash/shell redirection and sending that to a log file. The app should be
> > doing that internally.
> 
> That is what daemon is doing.

Yes but that's still Tomcat relying on jsvc or in my case
start-stop-daemon. Something EXTERNAL to Tomcat. That doesn't effect say
Tomcat out of the box when started via catalina.sh.

Again, other properties are being set in Bootstrap jar. I am
specifically asking if there is reason to not redirect stdout/stderr
there via system properties. Which would eliminate needing to do it
external of Tomcat be it shell redirection, jsvc, start-stop-daemon or
etc.

I am NOT looking for suggestions are alternatives like jsvc. I am
SPECIFICALLY asking if Tomcat Developers have considered doing the
redirection internally in Bootstrap or not. If it's been discussed, the
pros and cons. If it hasn't been discussed if it could be, and/or taken
under consideration for addition in future versions.

After thinking about it myself. I think I will likely take this approach
with most of my apps. I can surely made the mods to Bootstrap.java and
provide that via a patch on Gentoo. But I don't want to deviate from
upstream without at least discussing it first.

I am not looking to engage in a discussion of how to do this external to
tomcat via jsvc, bash/shell rediction, start-stop-daemon, or other
external means.

-- 
William L. Thomson Jr.
Gentoo/Java

Re: Bootstrap redirecting stdout/err via system.set

Posted by "William L. Thomson Jr." <wl...@gentoo.org>.
On Wed, 2007-11-28 at 18:28 +0100, jean-frederic clere wrote:
> William L. Thomson Jr. wrote:
> >
> > 
> > But I believe the argument is that applications should do their own
> > stderr/out redirection and not to it external of the app. As in not via
> > bash/shell redirection and sending that to a log file. The app should be
> > doing that internally.
> 
> That is what daemon is doing.

Was that referring to an external daemon, as in jsvc, or the Daemon as
part of the class that is called in Bootstrap and responsible for
starting Tomcat?

Seems odd no one has commented on this so far. Unless it's due to
ignorance on my behalf. I am not that familiar with Tomcat source code,
or internals on starting and etc. Slowly tracing things down there. So
please excuse my lack of knowledge or ignorance there.

Now I noticed several classes including Embedded make a System.setErr
call. If any of those are invoked as part of Boostrap starting, no clue
atm. But seems like if that logic exists in other place. If Boostrap or
something it called, invokes doesn't set that. Then it makes a good case
that it should be set. Since it's set when Tomcat is started via other
means.

I have since switched my own apps over to this. It's quite nice and
provides me a way to catch what otherwise might have been uncaught
exceptions. Via logging them to a file that I have redirected stderr and
stdout to.

-- 
William L. Thomson Jr.
Gentoo/Java

Re: Bootstrap redirecting stdout/err via system.set

Posted by jean-frederic clere <jf...@gmail.com>.
William L. Thomson Jr. wrote:
> On Wed, 2007-11-28 at 09:29 +0100, jean-frederic clere wrote:
>> William L. Thomson Jr. wrote:
>>> Recently on Gentoo I was looking to improve how we start Tomcat.
>>> Specifically how we capture stdout/stderr output from Tomcat on start
>>> and redirect it to catalina.out.
>> Have to tried to use jsvc from http://commons.apache.org/daemon/ for that?
> 
> We presently use start-stop-daemon. Which has some --stdout --stderr
> options coming. It nastily send that stuff to /dev/null, if the
> --background flag is passed along.
> 
> We had a long time bug/feature request for jsvc. I considered it, but
> elected to not go that route. If people want Tomcat on port 80 they can
> do port forwarding or etc. Which allows Tomcat to remaining running as a
> non-root user or etc. Nor the need for jsvc to accomplish that. So it's
> kinda moot.
> 
> But I believe the argument is that applications should do their own
> stderr/out redirection and not to it external of the app. As in not via
> bash/shell redirection and sending that to a log file. The app should be
> doing that internally.

That is what daemon is doing.

Cheers

Jean-Frederic

> 
> So if I am using start-stop-daemon, or jsvc. It doesn't really change
> that aspect.
> 


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


Re: Bootstrap redirecting stdout/err via system.set

Posted by "William L. Thomson Jr." <wl...@gentoo.org>.
On Wed, 2007-11-28 at 09:29 +0100, jean-frederic clere wrote:
> William L. Thomson Jr. wrote:
> > Recently on Gentoo I was looking to improve how we start Tomcat.
> > Specifically how we capture stdout/stderr output from Tomcat on start
> > and redirect it to catalina.out.
> 
> Have to tried to use jsvc from http://commons.apache.org/daemon/ for that?

We presently use start-stop-daemon. Which has some --stdout --stderr
options coming. It nastily send that stuff to /dev/null, if the
--background flag is passed along.

We had a long time bug/feature request for jsvc. I considered it, but
elected to not go that route. If people want Tomcat on port 80 they can
do port forwarding or etc. Which allows Tomcat to remaining running as a
non-root user or etc. Nor the need for jsvc to accomplish that. So it's
kinda moot.

But I believe the argument is that applications should do their own
stderr/out redirection and not to it external of the app. As in not via
bash/shell redirection and sending that to a log file. The app should be
doing that internally.

So if I am using start-stop-daemon, or jsvc. It doesn't really change
that aspect.

-- 
William L. Thomson Jr.
Gentoo/Java

Re: Bootstrap redirecting stdout/err via system.set

Posted by jean-frederic clere <jf...@gmail.com>.
William L. Thomson Jr. wrote:
> Recently on Gentoo I was looking to improve how we start Tomcat.
> Specifically how we capture stdout/stderr output from Tomcat on start
> and redirect it to catalina.out.

Have to tried to use jsvc from http://commons.apache.org/daemon/ for that?

Cheers

Jean-Frederic

 Presently due to our use of
> start-stop-daemon and some issues it comes with. We are using the normal
> redirection to capture the output. >> catalina.out 2>&1
> 
> In getting feedback to alternatives to our present approach, like that
> suggested in comment #5 on the following bug[1]. Another inquired as to
> why Tomcat wasn't capturing and redirecting it's own stdout/stderr via
> system properties?
> 
> Like how .home and .base are set now.
> 
> public void setCatalinaHome(String s) {
> 	System.setProperty( "catalina.home", s );
> }
> public void setCatalinaBase(String s) {
> 	System.setProperty( "catalina.base", s );
> }
> 
> Which would alleviate the need to capture and redirect that stuff
> externally of Tomcat. Is there a reason this is not currently done? Has
> this approach been considered before? Something like 
> 
> System.setOut(aPrintStream);
> System.setErr(aPrintStream);
> 
> Where the location would be configurable via a var or etc with a default
> specified.
> 
> Basically others are suggesting I write a wrapper class or etc to
> Bootstrap to set those properties there. I guess we could do that on
> Gentoo. But would like to get upstreams input there. Much less I would
> likely patch Bootstrap before wrapping it.
> 
> 
> http://bugs.gentoo.org/show_bug.cgi?id=162379
> 


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