I have this log4j.properties
in this path:
❯ 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
however, when I run my application I see in the console:
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].
here is my code:
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();
}
I'm using gradle
what am i missing?
I ran into this issue today myself.
All you need to do is use the file://
protocol before putting the path of the properties file for log4j to read.
So, your path will something be like
-Dlog4j.configuration=file:///Users/eladb/workspaceQa/MobileAutomationWebService/web-services/src/main/resources/log4j.properties
Hope it helps someone else by pointing them to the correct solution quickly :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With