When Tomcat deployments fail silently, the first place any experienced developer looks is the log files. But where exactly are they hiding in an Ubuntu installation? Here's what I discovered when my WAR file refused to start on Tomcat6.
In a default Ubuntu Tomcat6 installation via apt-get, there are several potential locations where logs might reside:
/var/lib/tomcat6/logs
/var/log/tomcat6
/usr/share/tomcat6/logs
The key revelation came from examining the jsvc process configuration:
$ ps -ax | grep jsvc
/usr/bin/jsvc [...] -outfile SYSLOG -errfile SYSLOG [...]
This explains why traditional log locations were empty - all output was being redirected to the system syslog.
To view Tomcat messages in syslog:
$ sudo grep tomcat /var/log/syslog
$ sudo grep jsvc /var/log/syslog
When standard approaches fail, try these advanced techniques:
# Check file descriptors of running process
$ for PID in $(pgrep jsvc); do sudo ls -l /proc/$PID/fd; done
# Find all files modified by tomcat user
$ sudo find / -user tomcat6 -mtime -1 -type f
For better log management, modify the startup configuration:
# Edit /etc/default/tomcat6
JAVA_OPTS="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties"
If you suspect memory constraints (common on VPS), check with:
$ free -m
$ sudo tail /var/log/syslog | grep -i memory
$ sudo tail /var/log/syslog | grep -i outofmemory
When logs remain elusive, this comprehensive approach helps:
# Stop Tomcat
$ sudo service tomcat6 stop
# Clear existing logs
$ sudo rm -f /var/log/tomcat6/*
$ sudo rm -f /var/lib/tomcat6/logs/*
# Restart with full logging
$ sudo service tomcat6 start
$ sudo tail -f /var/log/syslog | grep tomcat
When you install Tomcat6 on Ubuntu using apt-get install tomcat6
, the logging configuration differs from manual installations. The standard locations you'd expect (/var/lib/tomcat6/logs
) often appear empty because Ubuntu's package redirects logs to the system logging daemon.
The key information from your system output shows:
Tomcat is installed with CATALINA_HOME in /usr/share/tomcat6
CATALINA_BASE in /var/lib/tomcat6
The critical detail is the jsvc configuration line you found:
/usr/bin/jsvc -user tomcat6 ... -outfile SYSLOG -errfile SYSLOG ...
This explicitly tells Tomcat to write logs to the system logger rather than files.
To view your Tomcat logs in this configuration:
# View all system logs including Tomcat
sudo less /var/log/syslog
# Filter specifically for Tomcat entries
sudo grep tomcat /var/log/syslog
# Follow Tomcat logs in real-time
sudo tail -f /var/log/syslog | grep tomcat
If you prefer traditional log files, edit /etc/default/tomcat6
:
# Change from:
TOMCAT6_OPTS="-XX:+UseConcMarkSweepGC -Djava.awt.headless=true"
# To:
TOMCAT6_OPTS="-XX:+UseConcMarkSweepGC -Djava.awt.headless=true \
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
-Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties"
Then create/edit /var/lib/tomcat6/conf/logging.properties
with standard Tomcat logging configuration.
For WAR deployment issues, add this to your logging.properties
:
org.apache.catalina.core.ContainerBase.[Catalina].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].handlers = \
java.util.logging.ConsoleHandler, java.util.logging.FileHandler
This will give you detailed deployment logs that often reveal memory issues or dependency conflicts.
If you suspect memory issues, check with:
# Monitor Tomcat memory usage
sudo ps aux | grep tomcat
free -m
# Check for OutOfMemoryErrors in logs
sudo grep -i "outofmemory" /var/log/syslog
Consider adjusting memory settings in /etc/default/tomcat6
:
JAVA_OPTS="-Xms128m -Xmx256m -XX:MaxPermSize=128m"