1.之前是这么做的
PropertyConfigurator.configure("log4j.properties");
以为放在resources里面就可以直接读取,但是报异常
log4j:ERROR Could not read configuration file [log4j.properties].
java.io.FileNotFoundException: log4j.properties (系统找不到指定的文件。)
2.那就换一种方法
String path = OSSDemo.class.getClassLoader().getResource("log4j.properties").getPath(); PropertyConfigurator.configure(path);通过类加载器加载,就可以了