How to Use the Java Logging API in Apache Tomcat (Windows)
See Apache: Tips and Tricks for similar articles.
Developers and administrators alike will refer to Apache Tomcat logs from time for diagnostic and performance data. Tomcat uses a customized
implementation of java.util.logging called JULI (Java Utility Logging Implementation). JULI is very similar to standard Java SE logging, even
supporting the same configuration file, logging.properties. In this topic, we'll explore a way to route
the Catalina logs to a specific destination and then check out the log contents.
To learn how to use the Java Logging API in Apache Tomcat for Windows for these seven steps:
- Stop your Tomcat server.
- Directly under the C: drive on your computer create a folder named
logExercise. - Open
CATALINA_BASE/conf/logging.propertiesfor edit. Locate the following two lines:1catalina.org.apache.juli.AsyncFileHandler.level = INFO 1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs - Change the directory name to
c:/logExerciseas shown below:In addition, verify that the log level is1catalina.org.apache.juli.AsyncFileHandler.level = INFO 1catalina.org.apache.juli.AsyncFileHandler.directory = c:/logExerciseINFOas shown above. If the log level happens to be different, change it toINFO. - Save your changes.
- Start your Tomcat server.
- In your text editor, open the file you see under
c:/logExercise. Here is a portion of my log:
Note that
the log line output contains the date, time, log level, and a message.
Because of the log level of INFO, messages with a level of informational or more severe levels (e.g.,WARNING) are displayed.The screen shot above shows a warning message displayed among the informational messages.
