How to configure log4j with a properties file

前端 未结 9 1911
春和景丽
春和景丽 2020-11-29 03:01

How do I get log4j to pick up a properties file.

I\'m writing a Java desktop app which I want to use log4j. In my main method if have this:

   Proper         


        
9条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 03:40

    I have this code in my application today

    File log4jfile = new File("./conf/log4j.properties");
    PropertyConfigurator.configure(log4jfile.getAbsolutePath());
    

    The relative path is from the working directory of the JVM (where the JVM starts).

提交回复
热议问题