[slf4j-dev] svn commit: r1046 - in slf4j/trunk: jcl-over-slf4j/src/main/java/org/apache/commons/logging slf4j-site/src/site/pages
ceki at slf4j.org
ceki at slf4j.org
Thu Jun 5 17:55:53 CEST 2008
Author: ceki
Date: Thu Jun 5 17:55:52 2008
New Revision: 1046
Modified:
slf4j/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java
slf4j/trunk/slf4j-site/src/site/pages/codes.html
slf4j/trunk/slf4j-site/src/site/pages/news.html
Log:
- implemented methods added to o.a.c.l.LogFactory class in JCL 1.1
protected methods are "implemented" by throwing "UnsupportedOperationException" as the
invocation of these methods indicates the presence of both jcl-over-slf4j.jar as
well as commons-logging.jar on the class path.
Modified: slf4j/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java
==============================================================================
--- slf4j/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java (original)
+++ slf4j/trunk/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java Thu Jun 5 17:55:52 2008
@@ -20,48 +20,93 @@
/**
* <p>
- * Factory for creating {@link Log} instances, which always delegates to an instance of
- * {@link SLF4JLogFactory}.
+ * Factory for creating {@link Log} instances, which always delegates to an
+ * instance of {@link SLF4JLogFactory}.
*
* </p>
*
* @author Craig R. McClanahan
* @author Costin Manolache
* @author Richard A. Sitze
- * @author Ceki Gülcü
+ * @author Ceki Gülcü
*/
public abstract class LogFactory {
+ static String UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J = "http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j";
+
static LogFactory logFactory = new SLF4JLogFactory();
/**
+ * The name (<code>priority</code>) of the key in the config file used to
+ * specify the priority of that particular config file. The associated value
+ * is a floating-point number; higher values take priority over lower values.
+ *
+ * <p>
+ * This property is not used but preserved here for compatibility.
+ */
+ public static final String PRIORITY_KEY = "priority";
+
+ /**
+ * The name (<code>use_tccl</code>) of the key in the config file used to
+ * specify whether logging classes should be loaded via the thread context
+ * class loader (TCCL), or not. By default, the TCCL is used.
+ *
+ * <p>
+ * This property is not used but preserved here for compatibility.
+ */
+ public static final String TCCL_KEY = "use_tccl";
+
+ /**
* The name of the property used to identify the LogFactory implementation
* class name.
* <p>
* This property is not used but preserved here for compatibility.
*/
- public static final String FACTORY_PROPERTY =
- "org.apache.commons.logging.LogFactory";
+ public static final String FACTORY_PROPERTY = "org.apache.commons.logging.LogFactory";
/**
* The fully qualified class name of the fallback <code>LogFactory</code>
- * implementation class to use, if no other can be found.
+ * implementation class to use, if no other can be found.
*
- * <p>This property is not used but preserved here for compatibility.
+ * <p>
+ * This property is not used but preserved here for compatibility.
+ */
+ public static final String FACTORY_DEFAULT = "org.apache.commons.logging.impl.SLF4JLogFactory";
+
+ /**
+ * The name of the properties file to search for.
+ * <p>
+ * This property is not used but preserved here for compatibility.
+ */
+ public static final String FACTORY_PROPERTIES = "commons-logging.properties";
+
+ /**
+ * The name (<code>org.apache.commons.logging.diagnostics.dest</code>) of
+ * the property used to enable internal commons-logging diagnostic output, in
+ * order to get information on what logging implementations are being
+ * discovered, what classloaders they are loaded through, etc.
+ *
+ * <p>
+ * This property is not used but preserved here for compatibility.
+ */
+ public static final String DIAGNOSTICS_DEST_PROPERTY = "org.apache.commons.logging.diagnostics.dest";
+
+ /**
+ * <p>
+ * Setting this system property value allows the <code>Hashtable</code> used
+ * to store classloaders to be substituted by an alternative implementation.
+ * <p>
+ * This property is not used but preserved here for compatibility.
*/
- public static final String FACTORY_DEFAULT =
- "org.apache.commons.logging.impl.SLF4JLogFactory";
+ public static final String HASHTABLE_IMPLEMENTATION_PROPERTY = "org.apache.commons.logging.LogFactory.HashtableImpl";
/**
- * The name of the properties file to search for.
* <p>
* This property is not used but preserved here for compatibility.
*/
- public static final String FACTORY_PROPERTIES =
- "commons-logging.properties";
+ protected static LogFactory nullClassLoaderFactory = null;
-
/**
* Protected constructor that is not available for public use.
*/
@@ -75,7 +120,7 @@
* <code>null</code> if there is no such attribute.
*
* @param name
- * Name of the attribute to return
+ * Name of the attribute to return
*/
public abstract Object getAttribute(String name);
@@ -91,10 +136,11 @@
* <code>getInstance(String)</code> with it.
*
* @param clazz
- * Class for which a suitable Log name will be derived
+ * Class for which a suitable Log name will be derived
*
* @exception LogConfigurationException
- * if a suitable <code>Log</code> instance cannot be returned
+ * if a suitable <code>Log</code> instance cannot be
+ * returned
*/
public abstract Log getInstance(Class clazz) throws LogConfigurationException;
@@ -113,12 +159,13 @@
* </p>
*
* @param name
- * Logical name of the <code>Log</code> instance to be returned
- * (the meaning of this name is only known to the underlying logging
- * implementation that is being wrapped)
+ * Logical name of the <code>Log</code> instance to be
+ * returned (the meaning of this name is only known to the
+ * underlying logging implementation that is being wrapped)
*
* @exception LogConfigurationException
- * if a suitable <code>Log</code> instance cannot be returned
+ * if a suitable <code>Log</code> instance cannot be
+ * returned
*/
public abstract Log getInstance(String name) throws LogConfigurationException;
@@ -136,7 +183,7 @@
* there is no such attribute, no action is taken.
*
* @param name
- * Name of the attribute to remove
+ * Name of the attribute to remove
*/
public abstract void removeAttribute(String name);
@@ -146,10 +193,10 @@
* <code>removeAttribute(name)</code>.
*
* @param name
- * Name of the attribute to set
+ * Name of the attribute to set
* @param value
- * Value of the attribute to set, or <code>null</code> to remove
- * any setting for this attribute
+ * Value of the attribute to set, or <code>null</code> to
+ * remove any setting for this attribute
*/
public abstract void setAttribute(String name, Object value);
@@ -182,8 +229,8 @@
* </p>
*
* @exception LogConfigurationException
- * if the implementation class is not available or cannot be
- * instantiated.
+ * if the implementation class is not available or cannot
+ * be instantiated.
*/
public static LogFactory getFactory() throws LogConfigurationException {
return logFactory;
@@ -194,10 +241,11 @@
* to care about factories.
*
* @param clazz
- * Class from which a log name will be derived
+ * Class from which a log name will be derived
*
* @exception LogConfigurationException
- * if a suitable <code>Log</code> instance cannot be returned
+ * if a suitable <code>Log</code> instance cannot be
+ * returned
*/
public static Log getLog(Class clazz) throws LogConfigurationException {
return (getFactory().getInstance(clazz));
@@ -208,12 +256,13 @@
* to care about factories.
*
* @param name
- * Logical name of the <code>Log</code> instance to be returned
- * (the meaning of this name is only known to the underlying logging
- * implementation that is being wrapped)
+ * Logical name of the <code>Log</code> instance to be
+ * returned (the meaning of this name is only known to the
+ * underlying logging implementation that is being wrapped)
*
* @exception LogConfigurationException
- * if a suitable <code>Log</code> instance cannot be returned
+ * if a suitable <code>Log</code> instance cannot be
+ * returned
*/
public static Log getLog(String name) throws LogConfigurationException {
return (getFactory().getInstance(name));
@@ -226,7 +275,7 @@
* them.
*
* @param classLoader
- * ClassLoader for which to release the LogFactory
+ * ClassLoader for which to release the LogFactory
*/
public static void release(ClassLoader classLoader) {
// since SLF4J based JCL does not make use of classloaders, there is nothing
@@ -246,4 +295,66 @@
// to do here
}
+ /**
+ * Returns a string that uniquely identifies the specified object, including
+ * its class.
+ * <p>
+ * The returned string is of form "classname at hashcode", ie is the same as the
+ * return value of the Object.toString() method, but works even when the
+ * specified object's class has overidden the toString method.
+ *
+ * @param o
+ * may be null.
+ * @return a string of form classname at hashcode, or "null" if param o is null.
+ * @since 1.1
+ */
+ public static String objectId(Object o) {
+ if (o == null) {
+ return "null";
+ } else {
+ return o.getClass().getName() + "@" + System.identityHashCode(o);
+ }
+ }
+
+ // protected methods which were added in JCL 1.1. These are not used
+ // by SLF4JLogFactory
+
+ protected Object createFactory(String factoryClass, ClassLoader classLoader) {
+ throw new UnsupportedOperationException(
+ "Operation [factoryClass] is not supported in jcl-over-slf4j. See also "
+ + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
+ }
+
+ protected ClassLoader directGetContextClassLoader() {
+ throw new UnsupportedOperationException(
+ "Operation [directGetContextClassLoader] is not supported in jcl-over-slf4j. See also "
+ + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
+ }
+
+ protected ClassLoader getClassLoader(Class clazz) {
+ throw new UnsupportedOperationException(
+ "Operation [getClassLoader] is not supported in jcl-over-slf4j. See also "
+ + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
+ }
+
+ protected boolean isDiagnosticsEnabled() {
+ throw new UnsupportedOperationException(
+ "Operation [isDiagnosticsEnabled] is not supported in jcl-over-slf4j. See also "
+ + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
+ }
+
+ protected void logRawDiagnostic(String msg) {
+ throw new UnsupportedOperationException(
+ "Operation [logRawDiagnostic] is not supported in jcl-over-slf4j. See also "
+ + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
+ }
+
+ protected LogFactory newFactory(final String factoryClass,
+ final ClassLoader classLoader, final ClassLoader contextClassLoader) {
+ throw new UnsupportedOperationException(
+ "Operation [logRawDiagnostic] is not supported in jcl-over-slf4j. See also "
+ + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
+ }
+
+
}
\ No newline at end of file
Modified: slf4j/trunk/slf4j-site/src/site/pages/codes.html
==============================================================================
--- slf4j/trunk/slf4j-site/src/site/pages/codes.html (original)
+++ slf4j/trunk/slf4j-site/src/site/pages/codes.html Thu Jun 5 17:55:52 2008
@@ -25,12 +25,12 @@
</center>
- <a name="release">
- </a>
-
- <h3>The method
- <code>o.a.commons.logging.impl.SLF4FLogFactory#release</code>
- was invoked.
+ <h3>
+ <a name="release" href="#release">
+ The method
+ <code>o.a.commons.logging.impl.SLF4FLogFactory#release</code>
+ was invoked.
+ </a>
</h3>
<p>Given the structure of the commons-logging API, in particular
@@ -38,9 +38,10 @@
<code>o.a.commons.logging.impl.SLF4FLogFactory#release()</code>
method should never be called. However, depending on the
deployment of <em>commons-logging.jar</em> files in your servlet
- container, <code>release()</code> may be unexpectedly invoked by a
- copy of <code>org.apache.commons.logging.LogFactory</code> class
- shipping with <em>commons-logging.jar</em>.
+ container, <code>release()</code> method may be unexpectedly
+ invoked by a copy of
+ <code>org.apache.commons.logging.LogFactory</code> class shipping
+ with <em>commons-logging.jar</em>.
</p>
<p>This is a relatively common occurrence with recent versions of
@@ -59,12 +60,36 @@
#22</a>.</p>
+ <h3>
+ <a name="unsupported_operation_in_jcl_over_slf4j" href="#unsupported_operation_in_jcl_over_slf4j">
+ Operation [suchAndSuch] is not supported in jcl-over-slf4j.
+ </a>
+ </h3>
- <a name="StaticLoggerBinder">
- </a>
-
- <h3>Failed to load class
- <code>org.slf4j.impl.StaticLoggerBinder</code></h3>
+ <p>An <code>UnsuportedOperationException</code> is thrown whenever
+ one of the protected methods introduced in JCL 1.1 are
+ invoked. These methods are invoked by <code>LogFactory</code>
+ implementations shipping with
+ <em>commons-logging.jar</em>. However, the <code>LogFactory</code>
+ implemented by <em>jcl-over-slf4j.jar</em>, namely
+ SLF4FLogFactory, does not call any of these methods.
+ </p>
+
+ <p>If you observe this problem, then it is higly probable that you
+ have a copy of <em>commons-logging.jar</em> in your class path
+ overriding the classes shipping with
+ <em>jcl-over-slf4j.jar</em>. Note that this issue is very similar
+ in nature to the warning issued when the
+ "o.a.commons.logging.impl.SLF4FLogFactory.release()" method is
+ invoked, discussed in the previous item.
+ </p>
+
+ <h3>
+ <a name="StaticLoggerBinder" href="#StaticLoggerBinder">
+ Failed to load class
+ <code>org.slf4j.impl.StaticLoggerBinder</code>
+ </a>
+ </h3>
<p>This error is reported when the
<code>org.slf4j.impl.StaticLoggerBinder</code> class could not be
@@ -76,10 +101,10 @@
problem.
</p>
- <a name="null_LF">
- </a>
-
- <h3>Logging factory implementation cannot be null</h3>
+ <h3>
+ <a name="null_LF" href="#null_LF">Logging factory implementation
+ cannot be null</a>
+ </h3>
<p>This error is reported when the <code>LoggerFactory</code>
class could not find an appropriate binding. Placing one (and only
@@ -89,10 +114,13 @@
an effective remedy.
</p>
- <a name="no_static_mdc_binder">
- </a>
- <h3>Failed to load class "org.slf4j.impl.StaticMDCBinder".</h3>
+ <h3>
+ <a name="no_static_mdc_binder"
+ href="#no_static_mdc_binder">Failed to load class
+ "org.slf4j.impl.StaticMDCBinder"
+ </a>
+ </h3>
<p>This error indicates that appropriate SLF4J binding could not
be found on the class path. Placing one (and only one) of
@@ -102,21 +130,19 @@
problem.
</p>
- <a name="null_MDCA">
- </a>
-
- <h3>MDCAdapter cannot be null</h3>
+ <h3>
+ <a name="null_MDCA" href="#null_MDCA">MDCAdapter cannot be null
+ </a>
+ </h3>
<p>This error is reported when <code>org.slf4j.MDC</code> class
has not been initialized correctly. Same cause and remedy as the
previously listed item.
</p>
-
- <a name="log4j_version">
- </a>
- <h3>SLF4J versions 1.4.0 and later requires log4j 1.2.12 or later</h3>
+ <h3><a name="log4j_version" href="#log4j_version">SLF4J versions
+ 1.4.0 and later requires log4j 1.2.12 or later</a></h3>
<p>The trace level was added to log4j in version 1.2.12 released
on August 29, 2005. The trace level was added to the SLF4J API in
Modified: slf4j/trunk/slf4j-site/src/site/pages/news.html
==============================================================================
--- slf4j/trunk/slf4j-site/src/site/pages/news.html (original)
+++ slf4j/trunk/slf4j-site/src/site/pages/news.html Thu Jun 5 17:55:52 2008
@@ -37,8 +37,19 @@
report for this version</a>.</p>
<p>In order to support JCL version 1.1.1, the
- <em>jcl104-over-slf4j</em> module was renamed as
- <em>jcl-over-slf4j</em>.
+ <em>jcl<b>104</b>-over-slf4j</em> module was renamed as
+ <em>jcl-over-slf4j</em>. SLF4J will no longer ship with
+ <em>jcl104-over-slf4j.jar</em> but with <em>jcl-over-slf4j.jar</em>.
+ The related work responds to enhancement request discussed in <a
+ href="http://bugzilla.slf4j.org/show_bug.cgi?id=85">bug 85</a> as
+ reported by Niklas Gustavsson.
+ </p>
+
+ <p>Added a java.util.logging to SLF4J bridge as requested in <a
+ href="http://bugzilla.slf4j.org/show_bug.cgi?id=38">bug 38</a> by
+ Christian Stein, David Smiley, Johan Ferner, Joern Huxhorn and
+ others.
+ </p>
<p>Fixed <a href="http://bugzilla.slf4j.org/show_bug.cgi?id=68">bug
68</a> reported by Su Chuan and David Rauschenbach. SLF4J requires
More information about the slf4j-dev
mailing list