/**
* Initialize logging
*
* @param contextPath
*/
private void initLogging(String contextPath) {
System.out.println("Rafael: Initializing logging");
// enable appenders
String logPath = contextPath.substring(0,contextPath.indexOf("webapps"));
logPath += "logs/rafael/rafael.log";
try {
// default layout
Layout layout = new PatternLayout("%-5p: %d{yyyy-MM-dd HH:mm:ss,SSS} %c %x - %m%n");
// rolling file appender
DailyRollingFileAppender appender1 = new DailyRollingFileAppender(layout,logPath,"'.'yyyy-MM-dd");
BasicConfigurator.configure(appender1);
// console appender
ConsoleAppender appender2 = new ConsoleAppender(layout);
BasicConfigurator.configure(appender2);
}
catch(IOException e) {
System.out.println("Got an exception while initializing the logging configuration");
e.printStackTrace();
}
/*
* turn off all logging, and enable ERROR logging for the root package
* use restlet.LoggingResource to enable specific logging
*/
Logger.getRootLogger().setLevel(Level.OFF);
Logger.getLogger(PACKAGE_ROOT).setLevel(Level.INFO);
System.out.println("Rafael: Initializing logging done");
}
GlobalConfiguration.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:Rafael
作者:
评论列表
文章目录