Spring-jcl源码(四) -- LogFactory获取Log对象

public abstract class LogFactory {

	/**
	 * 获取给定类的Log对象
	 * Convenience method to return a named logger.
	 * @param clazz containing Class from which a log name will be derived
	 */
	public static Log getLog(Class clazz) {
		return getLog(clazz.getName());
	}

	/**
	 * 根据类名获取Log对象
	 * Convenience method to return a named logger.
	 * @param name logical name of the Log instance to be returned
	 */
	public static Log getLog(String name) {
		return LogAdapter.createLog(name);
	}


	/**
	 * 此方法只存在于与异常公共日志记录API兼容的情况下。
	 * This method only exists for compatibility with unusual Commons Logging API
	 * usage like e.g. {@code LogFactory.getFactory().getInstance(Class/String)}.
	 * @see #getInstance(Class)
	 * @see #getInstance(String)
	 * @deprecated in favor of {@link #getLog(Class)}/{@link #getLog(String)}
	 */
	@Deprecated
	public static LogFactory getFactory() {
		return new LogFactory() {};
	}

	/**
	 * Convenience method to return a named logger.
	 * 

This variant just dispatches straight to {@link #getLog(Class)}. * @param clazz containing Class from which a log name will be derived * @deprecated in favor of {@link #getLog(Class)} */ @Deprecated public Log getInstance(Class clazz) { return getLog(clazz); } /** * Convenience method to return a named logger. *

This variant just dispatches straight to {@link #getLog(String)}. * @param name logical name of the Log instance to be returned * @deprecated in favor of {@link #getLog(String)} */ @Deprecated public Log getInstance(String name) { return getLog(name); } }

LogFactory中getLog获取LogAdapter创建的Log对象。

你可能感兴趣的:(Java,spring,spring-jcl)