日期:2014-05-20 浏览次数:20724 次
public class LoggerFactory { static { try { URL resourceURL = LoggerFactory.class .getResource("/log4j.properties"); if(resourceURL != null) { PropertyConfigurator.configure(resourceURL); } else { PropertyConfigurator.configure("log4j.properties"); } } catch (Exception e) { e.printStackTrace(); } } public static Logger getLogger(String logName) { Logger logger = Logger.getLogger(logName); return logger; } public static Logger getLogger(final Class<?> clazz) { String className = clazz.getName(); return getLogger(className); } }