
com.magictools.log.dialect.commons.ApacheCommonsLogFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of magic-tools-all Show documentation
Show all versions of magic-tools-all Show documentation
magic-tools 是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。
The newest version!
package com.magictools.log.dialect.commons;
import com.magictools.log.Log;
import com.magictools.log.LogFactory;
/**
* Apache Commons Logging
* @author Looly
*
*/
public class ApacheCommonsLogFactory extends LogFactory{
public ApacheCommonsLogFactory() {
super("Apache Common Logging");
checkLogExist(org.apache.commons.logging.LogFactory.class);
}
@Override
public Log createLog(String name) {
try {
return new ApacheCommonsLog4JLog(name);
} catch (Exception e) {
return new ApacheCommonsLog(name);
}
}
@Override
public Log createLog(Class> clazz) {
try {
return new ApacheCommonsLog4JLog(clazz);
} catch (Exception e) {
return new ApacheCommonsLog(clazz);
}
}
@Override
protected void checkLogExist(Class> logClassName) {
super.checkLogExist(logClassName);
//Commons Logging在调用getLog时才检查是否有日志实现,在此提前检查,如果没有实现则跳过之
getLog(ApacheCommonsLogFactory.class);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy