浏览 1990 次
锁定老帖子 主题:两种方式加载log4j资源文件
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间: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); 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |