Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 451140 - www-servers/tomcat-7 does not log into catalina.out anymore
Summary: www-servers/tomcat-7 does not log into catalina.out anymore
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Java team
URL:
Whiteboard:
Keywords:
: 457520 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-01-10 09:35 UTC by Jérôme Revillard
Modified: 2023-03-07 08:07 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
log to catalina.out (diff.patch,711 bytes, patch)
2013-01-10 15:48 UTC, Jérôme Revillard
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jérôme Revillard 2013-01-10 09:35:48 UTC
The new tomcat-6/7 init scripts generated by tomcat-instance-manager.bash does not allow default logging inside catalina.out, here is a quick patch for that that has to be applied to /usr/share/tomcat-7/gentoo/tomcat.init and /usr/share/tomcat-6/gentoo/tomcat.init:

55a56,61
> 	if [ -z "$CATALINA_OUT" ] ; then
> 		CATALINA_OUT=/var/log/${RC_SVCNAME}/catalina.out
> 	fi
> 	touch "$CATALINA_OUT"
> 	chown ${CATALINA_USER}:${CATALINA_GROUP} "$CATALINA_OUT"
> 
60a67,68
> 		-1 "$CATALINA_OUT" \
> 		-2 "$CATALINA_OUT" \

Best,
Jerome

Reproducible: Always
Comment 1 Jérôme Revillard 2013-01-10 15:48:27 UTC
Created attachment 335080 [details, diff]
log to catalina.out
Comment 2 Ralph Sennhauser (RETIRED) gentoo-dev 2013-01-13 07:35:19 UTC
Agreed, we need something along those lines. To mention here is upstream catalina.sh always does set up a "CATALINA_OUT", the same way Jérôme Revillard does.

Skimming the old setup I can't see where it would have done that by default. Though the init script used to have a variable STD_OUT which could be used to opt-in for a "CATALINA_OUT", respectively to catch stdout / stderr separately if desired.
Comment 3 Gordon Pettey 2013-03-07 05:34:45 UTC
bug 457520 related?
Comment 4 Tiziano Müller (RETIRED) gentoo-dev 2013-10-16 14:01:40 UTC
*** Bug 457520 has been marked as a duplicate of this bug. ***
Comment 5 William L. Thomson Jr. 2015-08-25 14:03:42 UTC
I would close this as WONTFIX. The catalina.out is a legacy way of collecting output from stdout / stderr. Which is also sent to regular catalina.xxxx-xx-xx.log file. If you log to catalina.out, you will be essentially logging the same stuff twice. The only benefit is to keep those messages in their own file, but that does not prevent them from showing in the other.

A better way to address such would be to modify logging.properties to redirect java.util.logging.ConsoleHandler to catalina.out if so desired. That should log to one file rather than 2. That would allow anyone who needs legacy catalina.out to configure such, but others can do without.

Tomcat nor system logrotate manages catalina.out, so that file could grow and become problematic. Dealing with rotation is more work as you have to restart Tomcat. Presently Tomcat does its own rotation of logs it creates. Thus why you would not want catalina.out on a production system. It really is only useful in debugging, and/or development. Not to mention is a legacy way of handing stderr/stdout.


"Consider removing ConsoleHandler from configuration. By default (thanks to the .handlers setting) logging goes both to a FileHandler and to a ConsoleHandler. The output of the latter one is usually captured into a file, such as catalina.out. Thus you end up with two copies of the same messages."
https://tomcat.apache.org/tomcat-8.0-doc/logging.html#Considerations_for_production_usage

Rather than removing ConsoleHandler, just elected to not output to catalina.sh. But same thing, message are logged once vs twice. They are logged to a file tomcat rotates, so it cannot grow excessively. Worse case stderr/stdout message are mixed into other logging output. But they are prefixed, so its easy to grab those lines if needed.
Comment 6 Vieri 2019-06-14 11:10:45 UTC
I have tomcat 9, but I don't get any stdout in my logs. This is what I have:

# grep ConsoleHandler logging.properties
handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler
.handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter

I can't seem to find the way to log stdout or stderr except if I manually tweak the init script. The .log files do not have stdout or stderr.

This is my hacked init script with legacy catalina.out:

        start-stop-daemon  --start \
                --stdout /var/log/${RC_SVCNAME}/catalina.out \
                --stderr /var/log/${RC_SVCNAME}/catalina.err \
                --quiet --background \
                --chdir "${CATALINA_TMPDIR}" \
                --user ${CATALINA_USER}:${CATALINA_GROUP} \
                --make-pidfile --pidfile ${PIDFILE} \
                --exec ${JAVA_HOME}/bin/${cmd} \
                -- \
                        ${JAVA_OPTS} \
                        ${args} \
                        -Dcatalina.base="${CATALINA_BASE}" \
                        -Dcatalina.home="${CATALINA_HOME}" \
                        -Djava.io.tmpdir="${CATALINA_TMPDIR}" \
                        -Dgentoo.classpath="${GCLASSPATH//:/,}" \
                        -classpath "${CLASSPATH}" \
                        org.apache.catalina.startup.Bootstrap \
                        ${CATALINA_OPTS} \
                        ${TOMCAT_START}


Sure I'll have file size issues if I don't rotate the logs...
Comment 7 Jonas Stein gentoo-dev 2020-03-23 00:44:01 UTC
updated title, because 6 is no longer in the tree.
Comment 8 Volkmar W. Pogatzki 2023-03-07 08:07:10 UTC
www-servers/tomcat:7 is gone. Closing