2013/11/30 Christopher Schultz <ch...@christopherschultz.net>: > > On 11/27/13, 5:00 PM, Tomcat Random wrote: > >> "I find java.logging to be... frankly frustrating to configure." >> Totally agree, I feel like the Tomcat logging.properties file is >> weirdly clunky. > > Yes. That's because out of the box it uses java.util.logging, or > actually an adaptation of it. That choice was probably made to limit > the number of 3rd-party (though log4j is ASF) libraries required to > run Tomcat. Since java.util.logging comes with the JRE... may we wsll > use it. >
1) java.util.logging is always there, regardless of whether you use it or not. Even if you do not use it, you need to know that it exists and to be able to configure it. An empty conf/logging.properties file (mentioned in the "Log4J" section of the logging guide) is one of such explicit configurations. 2) Pure java.util.logging is frustrating at places. First, it is hard to configure (from API point of view). Tomcat's ClassLoaderLogManager solves this and makes it usable in multi-classloader environments. Internally it is not pretty, using ThreadLocals to pass information that cannot be passed via APIs, but it fills the gap. Note that ClassLoaderLogManager allows to use any 3-rd party java.util.logging libraries. The default configuration uses JRE-provided classes (e.g. ConsoleHandler). A Syslog JUL handler should exist somewhere, and from quick googling it does exist: [1] http://stackoverflow.com/questions/2311697/is-there-a-robust-java-util-logging-handler-implementation-of-syslog [2] http://code.google.com/p/agafua-syslog/ Second, it is hard to use java.util.logging APIs from the code that generates log information. The java.util.logging API is too generic and too limited in places. E.g. there exists java.util.logging.Logger.warning(String) method, but there is no warning(String, Throwable) method. One can call the Logger.log(Level,...) method, but essentially, one needs an adapter that provides more friendly interface. Apache Tomcat uses Apache Commons Logging as an adapter here. The commons logging classes are renamed into a different package, to avoid conflict if a web application uses the same library. 3) Personally, my logging experience started with Log4J 1. It was when Java 1.3 was the current version and java.util.logging did not exist. I do not use Log4J nowadays (all my needs are covered by JULI and Apache Commons Logging), but I still like to use their terminology like "categories" and "appenders". Best regards, Konstantin Kolinko --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org