vrijdag 7 maart 2008

Logging problems

Doing some unittests I could not get the logger to behave as expected. turned out that somewhere on the classpath commons-logging.properties was present.

System.out.println(this.getClass().getClassLoader().getResource("commons-logging.properties").toString());
System.out.println(this.getClass().getClassLoader().getResource("log4.jeroen").toString());
System.out.println(this.getClass().getClassLoader().getResource("log4j.properties").toString());
System.out.println(this.getClass().getClassLoader().getResource("org/apache/log4j/Logger.class").toString());
System.out.println(this.getClass().getClassLoader().getResource("org/apache/commons/logging/Log.class").toString());

Adding this file to the root of src/test/java folder fixed this problem.
contents of file is:
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
I've not been able to locate this file, can be on Websphere, Spring or god knows.

The combination of commons-logging, log4j is influencing a successful display of org.hibernate.type. The priority is set to trace, for this package name, but after log4j-1.2.12 is trace and debug separated, so debug is not working. This combination of log4j and commons-logging working for me is:

jar:file:/C:/projects/apache-log4j-1.2.15/log4j-1.2.15.jar!/org/apache/log4j/Logger.class
jar:file:/C:/projects/commons-logging-1.0.2/commons-logging-api.jar!/org/apache/commons/logging/Log.class
log4j.logger.org.hibernate.type=DEBUG, A1

It's getting trickier and trickier, maybe the introduction of commons-logging was a bad idea, especially in combination with Websphere.
logging information can be forced with log4j.debug=true

1 opmerking:

sander hautvast zei

commons-logging.properties can be found in plugins/com.ibm.ws.runtime_6.1.0.jar
Never mind that.
Make sure that a file called META-INF/services/org.apache.commons.logging.LogFactory is in the classpath
contents:
org.apache.commons.logging.impl.Log4jFactory
(just that)