This commit is contained in:
Gianpaolo Coro 2013-07-10 16:11:32 +00:00
parent c4c495fb9a
commit ed253ceaa7
1 changed files with 7 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import java.util.Properties;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.spi.RootLogger;
public class AnalysisLogger {
@ -21,7 +22,7 @@ public class AnalysisLogger {
org.apache.log4j.BasicConfigurator.configure();
// logger = Logger.getLogger("ConsoleAppender");
logger = Logger.getRootLogger();
logger.setLevel(Level.INFO);
logger.setLevel(Level.TRACE);
}
return logger;
@ -29,7 +30,9 @@ public class AnalysisLogger {
// in ingresso vuole il path al file di config del log4j
public static void setLogger(String path) {
if (logger == null) {
if (logger == null || (logger instanceof RootLogger)) {
System.out.println("EcologicalEnginLibrary: setting logger to "+path);
File f = new File(path);
if (f.exists())
PropertyConfigurator.configure(path);
@ -40,12 +43,14 @@ public class AnalysisLogger {
p.load(is);
is.close();
} catch (IOException e1) {
System.out.println("EcologicalEnginLibrary: Error in reading file"+path+" : "+e1.getLocalizedMessage());
}
PropertyConfigurator.configure(p);
}
}
logger = Logger.getLogger("AnalysisLogger");
hibernateLogger = Logger.getLogger("hibernate");
}
public static void printStackTrace(Exception e) {