方法一:
Properties prop = new Properties();
File f = new File("绝对路径");
FileInputStream is = null;
try {
is = new FileInputStream(f);
prop.load(is);
PropertyConfigurator.configure(prop);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
方法二:
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream is = null;
is = cl.getResourceAsStream("config/Log4j.properties");
Properties prop = new Properties();
prop.load(is);
PropertyConfigurator.configure(prop);
Properties prop = new Properties();
File f = new File("绝对路径");
FileInputStream is = null;
try {
is = new FileInputStream(f);
prop.load(is);
PropertyConfigurator.configure(prop);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
方法二:
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream is = null;
is = cl.getResourceAsStream("config/Log4j.properties");
Properties prop = new Properties();
prop.load(is);
PropertyConfigurator.configure(prop);