我有这个log4j.properties
在此路径中:
❯ ls -l /Users/eladb/workspaceQa/MobileAutomationWebService/web-services/src/main/resources/log4j.properties [15:54:01]
-rw-r--r-- 1 eladb eng 853 Jun 27 15:41 /Users/eladb/workspaceQa/MobileAutomationWebService/web-services/src/main/resources/log4j.properties但是,当我运行我的应用程序时,我在控制台中看到:
log4j: Trying to find [/Users/eladb/workspaceQa/MobileAutomationWebService/web-services/src/main/resources/log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@4e25154f.
log4j: Trying to find [/Users/eladb/workspaceQa/MobileAutomationWebService/web-services/src/main/resources/log4j.properties] using sun.misc.Launcher$AppClassLoader@4e25154f class loader.
log4j: Trying to find [/Users/eladb/workspaceQa/MobileAutomationWebService/web-services/src/main/resources/log4j.properties] using ClassLoader.getSystemResource().
log4j: Could not find resource: [/Users/eladb/workspaceQa/MobileAutomationWebService/web-services/src/main/resources/log4j.properties].下面是我的代码:
public class DeviceRepositoryFromJsonFile implements DeviceRepository {
final static Logger logger = Logger.getLogger(DeviceRepositoryFromJsonFile.class);
public DeviceRepositoryFromJsonFile() {
BasicConfigurator.configure();
filePath = Constants.devicesJsonPath;
jsonFileHandlerDevice = new JsonFileHandler<>(filePath);
devices = fetchFromFile();
}我正在使用gradle
我遗漏了什么?
发布于 2018-03-06 13:46:36
今天我自己也遇到了这个问题。
在为log4j读取属性文件的路径之前,您需要做的就是使用file://协议。
因此,您的路径将如下所示
-Dlog4j.configuration=file:///Users/eladb/workspaceQa/MobileAutomationWebService/web-services/src/main/resources/log4j.properties希望它能帮助其他人快速找到正确的解决方案:)
发布于 2016-06-27 21:04:20
请确保服务器未在根服务器文件夹中查找该文件夹
https://stackoverflow.com/questions/38054659
复制相似问题