We have a common common logging configuration between all the web applications on this system that we are trying to push to the tomcat level, instead of trying to process the level of a separate webapp. The webapps that use java.util.loggingturn out to be a bit complicated because we have a custom handler, and there seems to be no obvious way to make the custom handler play well with tomcat class loaders. At the moment, all this is at the prototype stage.
Preliminary: Tomcat 7.0.32, Java 6. Installing tomcat 7 by default using one REST service and nothing funny in the configuration.
First, roughly following the recommendations in this answer , I created a custom handler and placed the jar in $CATALINA_HOME/liband confirmed that the specified directory is in the correct directory and that common.loaderthis directory was included:
common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar
Then I changed the file logging.propertiesand added a handler:
handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler, my.custom.Handler
However, when I run ./startup.sh, I get the following:
[Loaded java.io.PrintWriter from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]
[Loaded java.util.logging.StreamHandler from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]
[Loaded java.util.logging.ConsoleHandler from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]
Handler error
java.lang.ClassNotFoundException: my.custom.Handler
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:521)
at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:464)
at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:288)
at java.util.logging.LogManager$2.run(LogManager.java:267) [...]
(This is s JAVA_OPTS=-verbose:class).
I saw that the corresponding classes are loaded later, but this does not look consistent and is probably an artifact of the aforementioned REST service (which used it directly).
I can make everything work correctly if I add jar in CLASSPATHdirectly, but this is usually not recommended, and not for modifying bootloaders.
- , , java.util.logging.Handler (, , ) logging.properties?
, , webapps java.util.logging.