类 LogFactory
- java.lang.Object
- org.apache.commons.logging.LogFactory
- 直接已知子类:
LogFactoryService
public abstract class LogFactory extends Object
A minimal incarnation of Apache Commons Logging'sLogFactory
API, providing just the commonLog
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: withLogFactory.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 tojava.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.- 从以下版本开始:
- 5.0
- 作者:
- Juergen Hoeller (for the
spring-jcl
variant)
构造器概要
构造器 构造器 说明 LogFactory()
方法概要
所有方法 静态方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 static LogFactory
getFactory()
已过时。in favor ofgetLog(Class)
/getLog(String)
Log
getInstance(Class<?> clazz)
已过时。in favor ofgetLog(Class)
Log
getInstance(String name)
已过时。in favor ofgetLog(String)
static Log
getLog(Class<?> clazz)
Convenience method to return a named logger.static Log
getLog(String name)
Convenience method to return a named logger.
构造器详细资料
LogFactory
public LogFactory()
方法详细资料
getLog
public static Log getLog(Class<?> clazz)
Convenience method to return a named logger.- 参数:
clazz
- containing Class from which a log name will be derived
getLog
public static Log getLog(String name)
Convenience method to return a named logger.- 参数:
name
- logical name of theLog
instance to be returned
getFactory
@Deprecated public static LogFactory getFactory()
已过时。in favor ofgetLog(Class)
/getLog(String)
This method only exists for compatibility with unusual Commons Logging API usage like e.g.LogFactory.getFactory().getInstance(Class/String)
.
getInstance
@Deprecated public Log getInstance(Class<?> clazz)
已过时。in favor ofgetLog(Class)
Convenience method to return a named logger.This variant just dispatches straight to
getLog(Class)
.- 参数:
clazz
- containing Class from which a log name will be derived
getInstance
@Deprecated public Log getInstance(String name)
已过时。in favor ofgetLog(String)
Convenience method to return a named logger.This variant just dispatches straight to
getLog(String)
.- 参数:
name
- logical name of theLog
instance to be returned