if (strs.length < 2)
throw new LogException("config format error");
int level = levelMap.get(strs[0]);
String path = strs[1];
FileLog fileLog = new FileLog();
fileLog.setName(name);
fileLog.setLevel(level);
if ("console".equalsIgnoreCase(path)) {
fileLog.setFileOutput(false);
fileLog.setConsoleOutput(true);
} else {
File file = new File(path);
if (!file.exists()) {
boolean mkdirRet = file.mkdirs();
if (!mkdirRet) {
throw new LogException("create dir " + path + " failure");
}
}
if (!file.isDirectory()) {
throw new LogException(path + " is not directory");
}
fileLog.setPath(path);
fileLog.setFileOutput(true);
if (strs.length > 2)
fileLog.setConsoleOutput("console".equalsIgnoreCase(strs[2]));
}
logMap.put(name, fileLog);
}
}