From: kkolinko keyPass connector attribute. (markt)
+
javax.servlet.ServletContext.log(...)
+ Use system logging API, java.util.logging.
java.util.logging.
+ Use the logging API provided by the Java Servlets specification,
+ javax.servlet.ServletContext.log(...)
Apache Tomcat has its own implementation of several key elements of
java.util.logging API. This implementation is called "JULI".
@@ -94,15 +96,33 @@
logging configurations. It is also notified by Tomcat when a web application
is unloaded from memory, so that the references to its classes can be
cleared, preventing memory leaks.
+
This java.util.logging implementation is enabled by providing
certain system properties when starting Java. The Apache Tomcat startup
scripts do this for you, but if you are using different tools to run
Tomcat (such as jsvc, or running Tomcat from within an IDE), you should
take care of them by yourself.
- More details about Tomcat JULI may be found below.
+ More details about java.util.logging may be found in the documentation
+ for your JDK and on its Javadoc pages for the java.util.logging
+ package.
+
+ More details about Tomcat JULI may be found below and in Tomcat Javadoc
+ for the org.apache.juli
+ package.
+
The calls to javax.servlet.ServletContext.log(...) to write
log messages are handled by internal Tomcat logging. Such messages are
logged to the category named
@@ -114,34 +134,31 @@
- Old applications that still use System.out or System.err
- can be tricked, by setting swallowOutput attribute on a
- Context. If the attribute is set to
- true, calls to System.out/err during request
- processing will be intercepted, and their output will be fed to the
- logging subsystem using the
- javax.servlet.ServletContext.log(...) calls.
- Note, that this feature is actually a trick,
- and works only with direct calls to System.out/err,
- and only during request processing cycle. It cannot be used to intercept
- logging frameworks that themselves write to the system streams,
- as those start early and may obtain a direct reference to the streams.
+ The Servlets logging API predates the java.util.logging API
+ that is now provided by Java. As such, it does not offer you much options.
+ E.g., you cannot control the log levels. It can be noted, though, that
+ in Apache Tomcat implementation the calls to ServletContext.log(String)
+ or GenericServlet.log(String) are logged at the INFO level.
+ The calls to ServletContext.log(String, Throwable) or
+ GenericServlet.log(String, Throwable)
+ are logged at the ERROR level.
- The default logging configuration in Apache Tomcat writes the same
- messages to the console and to a log file. This is great when using
- Tomcat for development, but usually is not needed in production.
When running Tomcat on unixes, the console output is usually redirected
- to a file named catalina.out. The name is configurable
+ to the file named catalina.out. The name is configurable
using an environment variable. (See the startup scripts).
- Whatever is written to System.err/out will be logged in
+ Whatever is written to System.err/out will be caught into
that file. That may include:
java.lang.ThreadGroup.uncaughtException(..)@@ -150,11 +167,41 @@
+ The default logging configuration in Apache Tomcat writes the same + messages to the console and to a log file. This is great when using + Tomcat for development, but usually is not needed in production. +
+ +
+ Old applications that still use System.out or System.err
+ can be tricked by setting swallowOutput attribute on a
+ Context. If the attribute is set to
+ true, the calls to System.out/err during request
+ processing will be intercepted, and their output will be fed to the
+ logging subsystem using the
+ javax.servlet.ServletContext.log(...) calls.
+ Note, that the swallowOutput feature is
+ actually a trick, and it has its limitations.
+ It works only with direct calls to System.out/err,
+ and only during request processing cycle. It may not work in other
+ threads that might be created by the application. It cannot be used to
+ intercept logging frameworks that themselves write to the system streams,
+ as those start early and may obtain a direct reference to the streams
+ before the redirection takes place.
+
A related, but different feature is access logging. It can be configured as a valve at the Context, or Host, or Engine. See Valves documentation for more details.
+$JAVA_HOME/jre/lib.
- Alternately, it can also use a global configuration file located elsewhere
- by using the system property java.util.logging.config.file,
- or programmatic configuration using
- java.util.logging.config.class.${catalina.base}/conf/logging.properties file.
+ The file is specified by the java.util.logging.config.file
+ System property which is set by the startup scripts.
+ If it is not readable or is not configured, the default is to use the
+ ${java.home}/lib/logging.properties file in the JRE.
+ WEB-INF/classes/logging.properties
+
- The default logging.properties specifies a ConsoleHandler for routing
- logging to stdout and also a FileHandler. A handler's log level threshold
- can be set using SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST or ALL.
- The logging.properties shipped with JDK is set to INFO. You can also target
- specific packages to collect logging from and specify a level. Here is how
- you would set debugging from Tomcat. You would need to ensure the
- ConsoleHandler's level is also set to collect this threshold, so FINEST or
- ALL should be set. Please refer to Sun's java.util.logging documentation for
- the complete details.
+ The default logging.properties in the JRE specifies a
+ ConsoleHandler that routes logging to System.err.
+ The default conf/logging.properties in Apache Tomcat also
+ adds several FileHandlers that write to files.
+
+ A handler's log level threshold is INFO by default and can be set using + SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST or ALL. + You can also target specific packages to collect logging from and specify + a level. +
+
+ Here is how you would set debugging from Tomcat. You would need to ensure the
+ ConsoleHandler's (or FileHandler's') level is also set to collect this threshold,
+ so FINEST or ALL should be set. Please refer to java.util.logging
+ documentation in the JDK for the complete details:
- The configuration used by JULI is extremely similar, but uses a few
+ The configuration used by JULI is extremely similar to the one supported by
+ plain java.util.logging, but uses a few
extensions to allow better flexibility in assigning loggers. The main
differences are:
22foobar. is a valid
prefix.loggerName.handlers property.loggerName.useParentHandlers property, which accepts a
boolean value..handlers property.bufferSize property of a handler. A value of 0
+ java.util.logging.Handler,
+ that can be used together with the ones provided by Java.
+ The notable one is org.apache.juli.FileHandlerorg.apache.juli.FileHandler supports buffering of the
+ logs. The buffering is not enabled by default. To configure it, use the
+ bufferSize property of a handler. The value of 0
uses system default buffering (typically an 8K buffer will be used). A
value of <0 forces a writer flush upon each log write. A
value >0 uses a BufferedOutputStream with the defined
value but note that the system default buffering will also be
applied.