4

I just recently deployed tomcat 9 and I would like to inspect the catalina.out log as it is running, however I notice that when stopped it would dump logging output to a catalina.[date].txt file. Is there some additional configuration to be done to enable live logging to catalina.out?

  • What's your OS. Windows or Linux and if Linux what version? – Dmitry Zayats Nov 29 '16 at 13:49
  • Just installed on Linux the last release of the 9 series, 9.0.0.M13, set up JAVA_HOME, started and stopped that (using startup.sh / shutdown.sh) and catalina.out is the same as in previous releases. – Fredi Nov 29 '16 at 16:44
  • @DmitryZayats I'm on an ubuntu 14.04 – Dark Star1 Nov 30 '16 at 7:58
  • @Fredi Unfortunately I can't tell you the exact version of my tomcat, but I grabbed the latest from the version from tomcat at the time. – Dark Star1 Nov 30 '16 at 9:32
3

By default at least on linux every version of Tomcat that i know of, writes the console log in $TOMCAT_HOME/logs/catalina.out or if defined $CATALINA_OUT, in the file name inside that var.

Actually this get's done from the start scripts, here's the relative part of the start script from Tomcat 9.0.0.M13 but other versions do the same, file: $TOMCAT_HOME/bin/startup.sh which calls catalina.sh :

startup.sh:

#!/bin/sh 

[...]

PRGDIR=`dirname "$PRG"`
EXECUTABLE=catalina.sh

[...]

exec "$PRGDIR"/"$EXECUTABLE" start "$@"

catalina.sh:

#!/bin/sh

[...]

#   CATALINA_OUT    (Optional) Full path to a file where stdout and stderr
#                   will be redirected.
#                   Default is $CATALINA_BASE/logs/catalina.out

[...]

if [ -z "$CATALINA_OUT" ] ; then
  CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
fi

[...]

elif [ "$1" = "start" ] ; then

[...]

    eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
      -classpath "\"$CLASSPATH\"" \
      -Dcatalina.base="\"$CATALINA_BASE\"" \
      -Dcatalina.home="\"$CATALINA_HOME\"" \
      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
       org.apache.catalina.startup.Bootstrap "$@" start \
       >> "$CATALINA_OUT" 2>&1 "&"



So, either you're setting that var somewhere, or you're starting tomcat without using the start scripts.

| improve this answer | |
  • Apologies for not getting back sooner, but I have been away. Everything is fine script wise and I am starting tomcat with a script in the init.d directory which calls the startup.sh the the bin directory.: /bin/su $TOMCAT_USER -c $CATALINA_HOME/bin/startup.sh Also I must mention that tomcat is writing the rotate logs in this directory so it is aware of it else-wise the directory would be empty. – Dark Star1 Dec 12 '16 at 9:59
  • @DarkStar1, okay, but as you can see from the original scripts the console log file (different from the java logging libraries) is handled from the shell, and is called catalina.out, not the .txt you mentioned ... so i'm a bit confused :) – Fredi Dec 16 '16 at 16:00
0

Ubuntu 18.04 and 20.04 now use 'systemd' and log to the journal. To change that, do the following:

Edit the file: /lib/systemd/system/tomcat9.service

Comment out the line: SyslogIdentifier=tomcat9

and add these two lines:

StandardOutput=append:/var/log/tomcat9/catalina.out
StandardError=append:/var/log/tomcat9/catalina.out
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.