论坛首页 入门技术论坛

两种方式加载log4j资源文件

浏览 1953 次
该帖已经被评为新手帖
作者 正文
   发表时间:2008-06-29  
方法一:
Properties prop = new Properties();
File f = new File("绝对路径");
FileInputStream is = null;

try {
is = new FileInputStream(f);
prop.load(is);
PropertyConfigurator.configure(prop);
} catch (FileNotFoundException e) {
e.printStackTrace();
}

方法二:
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream is = null;
is = cl.getResourceAsStream("config/Log4j.properties");
Properties prop = new Properties();
prop.load(is);
PropertyConfigurator.configure(prop);
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics