public class ExampleLog {
private final String LOGFILE = "log4j.properties";
private ExampleLog() {
InitLog();
}
private static ExampleLog log = null;
public static ExampleLog initExampleLog() {
if (log == null) {
log = new ExampleLog();
}
return log;
}
private void InitLog() {
String logPro = LOGFILE;
InputStream url1 = ExampleLog.class.getResourceAsStream(logPro);
Properties p = new Properties();
try {
p.load(url1);
} catch (IOException e) {
p = null;
e.printStackTrace();
}
if (p != null) {
PropertyConfigurator.configure(p);
}
}
}
Log4j Example
最新推荐文章于 2024-10-09 11:24:26 发布