Logging is critical for Web applications, as often there is no other way to debug issues on production machines. Also, adding log statements is the only viable option for analyzing the execution of a long-running Web application.
This chapter discusses logging, both internally by Tomcat as well as by Web applications themselves. This chapter covers the following:
A short, tutorial-style introduction to both log4j and Java Logging.
Logging concepts and best practices, such as rolling logs, maintaining information in log messages to be able to identify the source of the error, and much more.
Solutions ("recipes") for common tasks that developers and system administrators need to do while developing effective logging solutions for their applications. Some of these include:
Logging to different destinations, such as a file, system console, or even the system logger (syslog, NT logger)
Being able to notify administrators via e-mail of specific log messages, such as serious errors
The chapter also introduces administrators to tools that they can use to manage the large amount of log data generated.
There are two big changes in logging since Tomcat 5:
Tomcat 6 has done away with the
<Logger> element defined in the
server.xml that sent internal Tomcat messages to the
localhost_log. Instead, you use the Java Logging property file
<CATALINA_HOME>/conf/logging.properties to configure logging. See the section on JULI for more information on Java Logging configuration ...