0
I’m having trouble reading a.properties. file.I created a separate class with a static method. However, it throws an exception and returns null.
Follow my code below.
public class LoadLog4jProperty {
protected static final Logger log = LogManager.getLogger();
public static void loagLog4jProperty() {
String logPath = "back/src/main/resource/log4j.properties";
Properties propertyFile = new Properties();
try {
propertyFile.load(new FileInputStream(logPath));
PropertyConfigurator.configure(propertyFile);
} catch (IOException e) {
log.warn("Log não configurado corretamente: " + e.getMessage() );
}
}
}
Project structure:
What am I doing wrong??
How else can I read a file.properties??
Kindly post the structure of your project, probably the way
back/src/main/resource/log4j.properties
pointed is incorrect. Just try/resource/log4j.properties
– nullptr
@ngueno posted the structure
– Gabriel Hardoim
Gabriel, try the @ngueno suggestion, but first hit the name of your "Resource" folder, the correct is "Resources".
– Badaro