/**
* read log4j properties from user defined location or default location
* @throws FileNotFoundException
*/
public void reconfigLog() throws FileNotFoundException {
File location = _configuration.getLogConfig();
Level llevel = _configuration.loglevel;
Logger.getRootLogger().removeAllAppenders();
progressAndResultLog.setAdditivity(false);
// user provided log location?
if (location != null) {
if (!location.exists())
{
System.err.printf("User provided log location does not exist: %s", location);
System.exit(1);
}
PropertyConfigurator.configure(new FileInputStream(location));
log.info("user has provided log level location: " + location);
}
// user has given a global log level
else if (llevel != null) {
ConsoleAppender c = new ConsoleAppender();
c.setLayout(new PatternLayout("%-4r [%t] %-5p %l - %m%n"));
c.setThreshold(llevel);
c.activateOptions();
Logger.getRootLogger().addAppender(c);
log.info("user set log level to " + llevel.toString());
}
// do we have a log file at the default location
else if (new File(LOG4JPROPERIES_DEFAULT_LOCATION).exists())
{
defaultLogPropertyFileConfig();
log.info("use default log properties location " + LOG4JPROPERIES_DEFAULT_LOCATION);
}
// just set everything to error log level
else {
defaultLogConfig();
}
outputLog(llevel == null ? Level.INFO : llevel);
}
iBench.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:ibench
作者:
评论列表
文章目录