[英]log4j.properties (No such file or directory)
我正在使用maven和log4j,但是应用程序无法加载WAR文件中“ /”和“ / WEB-INF / classes /”中的log4j.properties。
在我的Java代码中:
try {
Properties props = new Properties();
props.load(new FileInputStream("log4j.properties"));
PropertyConfigurator.configure(props);
} catch (Exception e) {
...
}
我的pom.xml是否需要额外的配置? (除了依赖项)
先感谢您。
尝试使用
InputStream is = this.getClass().getClassLoader().getResourceAsStream("log4j.properties");
您也可以尝试以下方法:
PropertyConfigurator.configure(getClass().getResource("/<path if any>/log4j.properties"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.