Top Description Constructors Methods
org.apache.commons.logging

public abstract Class LogFactory

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.commons.logging.LogFactoryService

A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log lookup methods. This is inspired by the JCL-over-SLF4J bridge and should be source as well as binary compatible with all common use of the Commons Logging API (in particular: with LogFactory.getLog(Class/String) field initializers).

This implementation does not support Commons Logging's original provider detection. It rather only checks for the presence of the Log4j 2.x API and the SLF4J 1.7 API in the Spring Framework classpath, falling back to java.util.logging if none of the two is available. In that sense, it works as a replacement for the Log4j 2 Commons Logging bridge as well as the JCL-over-SLF4J bridge, both of which become irrelevant for Spring-based setups as a consequence (with no need for manual excludes of the standard Commons Logging API jar anymore either). Furthermore, for simple setups without an external logging provider, Spring does not require any extra jar on the classpath anymore since this embedded log factory automatically delegates to java.util.logging in such a scenario.

Note that this Commons Logging variant is only meant to be used for infrastructure logging purposes in the core framework and in extensions. It also serves as a common bridge for third-party libraries using the Commons Logging API, e.g. Apache HttpClient, and HtmlUnit, bringing them into the same consistent arrangement without any extra bridge jars.

For logging need in application code, prefer direct use of Log4j 2.x or SLF4J or java.util.logging. Simply put Log4j 2.x or Logback (or another SLF4J provider) onto your classpath, without any extra bridges, and let the framework auto-adapt to your choice.

Author
Juergen Hoeller (for the spring-jcl variant)
Since
5.0

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract Object
getAttribute(String name)

Deprecated
public abstract String[]
getAttributeNames()

Deprecated
public static LogFactory
getFactory()

Deprecated in favor of getLog(Class)/getLog(String)
This method only exists for compatibility with unusual Commons Logging API usage like e.g. LogFactory.getFactory().getInstance(Class/String).
public Log
getInstance(Class<?>
containing Class from which a log name will be derived
clazz
)

Deprecated in favor of getLog(Class)
Convenience method to return a named logger.
public Log
getInstance(String
logical name of the Log instance to be returned
name
)

Deprecated in favor of getLog(String)
Convenience method to return a named logger.
public static Log
getLog(Class<?>
containing Class from which a log name will be derived
clazz
)

Convenience method to return a named logger.

public static Log
getLog(String
logical name of the Log instance to be returned
name
)

Convenience method to return a named logger.

public static String
objectId(Object o)

Deprecated
public abstract void
release()

Deprecated
public static void
release(ClassLoader classLoader)

Deprecated
public static void
releaseAll()

Deprecated
public abstract void
removeAttribute(String name)

Deprecated
public abstract void
setAttribute(String name, Object value)

Deprecated
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

LogFactoryback to summary
public LogFactory()

Method Detail

getAttributeback to summary
public abstract Object getAttribute(String name)

Deprecated

Annotations
@Deprecated
getAttributeNamesback to summary
public abstract String[] getAttributeNames()

Deprecated

Annotations
@Deprecated
getFactoryback to summary
public static LogFactory getFactory()

Deprecated

in favor of getLog(Class)/getLog(String)

This method only exists for compatibility with unusual Commons Logging API usage like e.g. LogFactory.getFactory().getInstance(Class/String).

Annotations
@Deprecated
See Also
getInstance(Class), getInstance(String)
getInstanceback to summary
public Log getInstance(Class<?> clazz)

Deprecated

in favor of getLog(Class)

Convenience method to return a named logger.

This variant just dispatches straight to getLog(Class).

Parameters
clazz:Class<?>

containing Class from which a log name will be derived

Annotations
@Deprecated
getInstanceback to summary
public Log getInstance(String name)

Deprecated

in favor of getLog(String)

Convenience method to return a named logger.

This variant just dispatches straight to getLog(String).

Parameters
name:String

logical name of the Log instance to be returned

Annotations
@Deprecated
getLogback to summary
public static Log getLog(Class<?> clazz)

Convenience method to return a named logger.

Parameters
clazz:Class<?>

containing Class from which a log name will be derived

getLogback to summary
public static Log getLog(String name)

Convenience method to return a named logger.

Parameters
name:String

logical name of the Log instance to be returned

objectIdback to summary
public static String objectId(Object o)

Deprecated

Annotations
@Deprecated
releaseback to summary
public abstract void release()

Deprecated

Annotations
@Deprecated
releaseback to summary
public static void release(ClassLoader classLoader)

Deprecated

Annotations
@Deprecated
releaseAllback to summary
public static void releaseAll()

Deprecated

Annotations
@Deprecated
removeAttributeback to summary
public abstract void removeAttribute(String name)

Deprecated

Annotations
@Deprecated
setAttributeback to summary
public abstract void setAttribute(String name, Object value)

Deprecated

Annotations
@Deprecated