教程集 www.jiaochengji.com
教程集 >  脚本编程  >  Jsp  >  正文 linux下相对路径加载Log4j配置文件

linux下相对路径加载Log4j配置文件

发布时间:2015-09-24   编辑:jiaochengji.com
本文介绍下,在linux系统中,使用相对路径加载log4j配置文件的方法,有需要的朋友参考下。

使用相对路径加载log4j配置文件。
例子:
 

复制代码 代码示例:
URL url  =  UserServiceImpl. class .getResource( " /config/log4j.properties " );
Properties properties  =   new  Properties();
try  {
     properties.load( new  InputStreamReader(url.openStream()));
    }  catch  (IOException e) {
        e.printStackTrace();
    }
PropertyConfigurator.configure(properties);

说明:
/config/log4j.properties
可以放在对应的jar文件中。

您可能感兴趣的文章:

[关闭]
~ ~