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 07: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 09:32
3 Answers
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
![](../../users/profiles/335980.webp)
- 141
- 3
-
I tried this way. And I also did systemctl daemon-reload and systemctl restart tomcat9. There is still no /var/log/tomcat9/catalina.out. I use Ubuntu Server 18.04.5 LTS. So, any further suggestion ? – wureka Nov 08 '20 at 05:03
-
1This worked for me on Ubuntu 20.04. However, `systemd` intends for the service files in `/lib/systemd/system/` not to be edited by the user. Instead, users should create `/etc/systemd/system/tomcat9.service.d/override.conf` and place these corrections there. "Commenting" can be accomplished by setting the parameter to nothing, i.e. `SyslogIdentifier=` – Borea Deitz May 25 '21 at 19:03
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
![](../../users/profiles/800878.webp)
- 31
- 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.
![](../../users/profiles/320180.webp)
- 2,227
- 9
- 13
-
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 09: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