Where is catalina.out in tomcat 9?

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?


Solution 1:

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.

Solution 2:

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

Solution 3:

Tomcat 9 uses systemd for its standard output. You can override this by calling sudo systemctl edit tomcat9

this will create a file /etc/systemd/system/tomcat9.service.d/override.conf. Here you should add the overrides under the proper tag [Service] :

[Service]
StandardOutput=append:/var/log/tomcat9/catalina.out
StandardError=append:/var/log/tomcat9/catalina.out
SyslogIdentifier=

This is a combination of the answers given by Ted, Borea and https://askubuntu.com/questions/659267/how-do-i-override-or-configure-systemd-services