/**
* Setup the Log4J logger for this action thread.
* @return String path to log file
* @throws IOException If there's something wrong with the FileAppender.
*/
private void setupLog4jForAction() throws IOException {
String loggerName = "Action_" + this.id;
org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger("Action_" + this.id);
String logRoot = System.getProperty("LOG_ROOT");
if(logRoot == null) {
logRoot = ".";
}
String logFilePath = logRoot + "/charles-rest/ActionsLogs/" + this.id + ".log";
File logFile = new File(logFilePath);
logFile.getParentFile().mkdirs();
logFile.createNewFile();//you have to create the file yourself since FileAppender acts funny under linux if the file doesn't already exist.
FileAppender fa = new FileAppender(new PatternLayout("%d %p - %m%n"), logFilePath);
fa.setName(this.id + "_appender");
fa.setThreshold(Level.DEBUG);
log4jLogger.addAppender(fa);
log4jLogger.setLevel(Level.DEBUG);
this.logger = LoggerFactory.getLogger(loggerName);
}
Action.java 文件源码
java
阅读 32
收藏 0
点赞 0
评论 0
项目:charles-rest
作者:
评论列表
文章目录