package ru log4j import org apache log4j Logger import org apache log4

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package ru.log4j;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class Application {
public Application() {
String homeDir = System.getProperty("user.dir");
System.out.println(homeDir);
Properties prop = new Properties();
InputStream is = getClass().getResourceAsStream("/resources/log4j.properties");
try {
prop.load(is);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
PropertyConfigurator.configure(prop);
Logger log = Logger.getLogger(Application.class);
log.info("hello");
}
public static void main(String[] args) {
new Application();
}
}