需求:
打印:含有类名,message信息
使用的jar包:log4j
应用:Log.debug(Object caller, LogInfo loginfo, String Message)
Log.isDebugEnabled (Object caller)
Log.info(Object caller, LogInfo loginfo, String Message)
Log.warn(Object caller, LogInfo loginfo, String Message)
Log.error(Object caller, LogInfo loginfo, String Message)
Log.fatal(Object caller, LogInfo loginfo, String Message)
设计接口:interface LogWrapper
含有方法:debug(),isDebugEnabled(), info(),warn(),error(),fatal()
对应于应用需要以上接口方法。
实例:LogWrapperFactory()
Static synchronized LogWrapper.getInstance()
Static synchronized LogWrapper.getInstance(String classname)
处理详细:
没有实例时,加载Class.forName(),有实例,原样返回。
类名取得:如:Log4jLogWrapper
interface LogWrapper的log4j实现:
public class Log4jLogWrapper implements LogWrapper{}
LogInfo implements serilizable{}
用到java包:commons-logging-1.1.1.jar,
slf4j-api-1.5.11.jar
log4j-1.2.17.jar
log4j.