/** * 从配置文件中查找并创建日志工厂 * * @param config */ public static void configure(Configuration config) { String factoryClass = config.getConfig().getChild("log-manager").getChildText("factory-class"); LogFactory factory = (LogFactory) ReflectHelper.newInstance( ReflectHelper.forName(factoryClass), new Class[] {Configuration.class}, new Object[] {config}); setLogFactory(factory); }
/** * 返回日志工厂, 如果没有设置日志工厂,将创建一个默认的日志处理工厂 * * @return 日志工厂 */ public static LogFactory getLogFactory() { if (logFactory != null) { return logFactory; } Configuration config = null; try { config = Configuration.getConfiguration(); } catch (Exception e) { } if (config == null) { return new DefaultLogFactory(null); } else { configure(config); return logFactory; } }