[slf4j-dev] Service Provider Interface (using jcl104-over-slf4j.jar with axis.jar)
Dave Wallace
dwallace at UDel.Edu
Tue Mar 21 16:25:34 CET 2006
Hello,
I recently encountered some trouble adding axis.jar to an existing
project that uses slf4j and jcl104-over-slf4j.jar to take over logging
for hibernate and a few other apache commons jars.
The application failed to load axis.jar until I set this property on the
Java VM command line:
-Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.SLF4FLogFactory.
As it turns out, axis.jar uses commons-logging but through a
commons-discovery mechanism that looks for a factory implementation
based on the value of a property with a name from
org.apache.commons.logging.LogFactory.FACTORY_PROPERTY. Hence the
property is required, but this led me to look a little deeper into the
discovery mechanism.
Following
http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Service%20Provider
I added a file named
"/META-INF/services/org.apache.commons.logging.LogFactory" to
jcl104-over-slf4j.jar. The file contained a single line naming
org.apache.commons.logging.impl.SLF4FLogFactory as a provider of the
LogFactory service. With this modification the property is no longer
necessary.
Do you think this might be a good thing to add to the jar permanently so
that whenever jcl104-over-slf4j.jar is dropped in the classpath it
becomes a provider of the org.apache.commons.logging.LogFactory service?
- Dave
More information about the slf4j-dev
mailing list