“Explain to an experienced sysadmin who knows nothing about Tomcat or Java (but a lot about system utilities etc) how to set up a coherent and easy-to-manage logging system for Tomcat (and applications therein), including (safe) log rotation, archiving, cleanup etc.”
André Warnier
Access logs
Tomcat logs
Application logs
There are lots
There are even frameworks for the frameworks
JRE came a little late to the party
Similar to log4j
Loggers are in a hierarchy
org
org.apache
org.apache.tomcat
Typically follows Java package hierarchy
Logger names typically match class names
Don't have to
Set levels at any point in the hierarchy
Add handlers at any point in the hierarchy
Option to pass log message up hierarchy
Is not class loader aware
Configuration file only allows one instance of a Handler type
Java Util Logging Implementation
Commons logging hard-coded to use java.util.logging
Class loader aware
Allows multiple handlers of same type
A closer look at Tomcat's default logging.properties
Remove the ConsoleHandler
Nothing should output to STDOUT or STDERR during normal operations
catalina.YYYY-MM-DD.log should be mostly empty
Deployment and undeployment may trigger some logging
Servlet API provides very basic logging
log(String)
log(String, Throwable)
Not sufficiently flexible for most use cases
Could use anything
Direct to stdout
Servlet API
Logging framework routed to files
Logging framework routed to stdout
java.util.logging
Configure to files outside of docBase
Configure to redirect to java.util.logging
then configure via JULI
Passed to Container's logger
log(String)
at INFO
log(String, Throwable)
at ERROR
Configure via JULI
stdout
Or stderr
Time for a training course
swallowOutput
on Context
All output for one request gets redirected to a single INFO
log messages
rotation: rotatable
(daily rotation)
archiving: no support
clean-up: maxDays
Logs every request
Separate from logging framework
Optimised for performance
rotation: rotatable
, fileDateFormat
, renameOnRotate
archiving: no support
clean-up: maxDays
JSP that outputs to stdout