Logging and Monitoring

Harry · 12 Sep 2026 · 8 views

What You Get

logs/
├── catalina.out      # gobbling system/gc log; main startup log
├── catalina.2026-09-12.log
├── localhost.2026-09-12.log  # exceptions in apps
├── manager.2026-...          # manager app logs
└── localhost_access_log.*.txt

Enable Access Logs

Add a Valve to your Host in server.xml to record every request:

<Valve className="org.apache.catalina.valves.AccessLogValve"
       directory="logs" prefix="localhost_access_log" suffix=".txt"
       pattern="%h %l %u %t "%r" %s %b"/>

%h = remote host, %t = time, %r = request line, %s = status, %b = bytes. Analyise with GoAccess or awk to find slow or failing URLs.

Application Logging (SLF4J/Log4j)

Tomcat ships with its own logging (JULI). Configure per-app logging under WEB-INF/classes/logging.properties to send app logs to files without polluting catalina.out.

Monitoring Essentials

  • jps / jstack - inspect the Tomcat JVM process.
  • JMX to expose heap, threads and connector stats for Grafana/Prometheus.
  • Watch disk usage in logs and work; rotate access logs daily.
  • Alert on OutOfMemoryError and on long response times in access logs.

Key Points

  • localhost log = your app stack traces; catalina.out = server events.
  • Access logs are the cheapest observability you can enable.
  • Rotate and old Log rotation avoids eating disk over months.
Share this post:

Comments (0)

Please login or register to comment.