PDA

View Full Version : JDK1.4 Logging


femibyte
Aug 27th, 2004, 04:29 PM
How do I configure Spring to use JDK 1.4 logging? I prefer not to use log4j since that we use JDK1.4 logging at our company. Spring uses log4j by default.

Thanks in adavnce,
Femi

irbouho
Aug 27th, 2004, 04:45 PM
Spring uses Jakarta Commons Logging. The later uses log4j if it is found in your classpath.
Since you use JDK1.4, just remove log4j.jar from your classpath, and JCL will use JDK logging.
For more information take a look at http://jakarta.apache.org/commons/logging/commons-logging-1.0.4/docs/guide.html#Configuration

femibyte
Aug 30th, 2004, 05:07 AM
I auto-generate my class path to add all jar files within a directory to my class path and I'd rather keep my log4j.jar file there. I think one can set a property to specify which kind of logging to use with this system property:
java.util.logging.config.class
as specified in http://java.sun.com/j2se/1.4.2/docs/api/java/util/logging/LogManager.htm
How would I set up this System property file in the Spring applicationContext.xml file?

Colin Sampaleanu
Aug 30th, 2004, 09:07 AM
You can't set the system property from Spring itself, since it will be too late. (Thsi is assuming the appserver security environment even let's you set system properties). Spring will have already tried to log something, so log4j will have been initialized.

If you can not modify your appserver environment to just start up the appserver with this property already set, what you could try doing is setting the system property in a web app context loader listener which is registered to be the first one loaded, when your webapp loads.