Upload.properties file

Asked

Viewed 70 times

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:

Estrutura do projeto:

  • 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

  • @ngueno posted the structure

  • Gabriel, try the @ngueno suggestion, but first hit the name of your "Resource" folder, the correct is "Resources".

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.