使用相对路径加载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文件中。