日誌框架實現實時修改,實時生效,具體框架思路(4)

代碼接第(3)章

fw.write(ENTER_CODE);
for (LogConfigBean lc : list) {
writeLogWithModule(fw, lc);
fw.write(ENTER_CODE);
}
} catch (FileNotFoundException e) {
LOG.error("file " + backFile.getAbsolutePath() + " not found \n"
+ e.getMessage());
} catch (IOException e) {
LOG.error("file " + backFile.getAbsolutePath() + " IOException \n"
+ e.getMessage());
} finally {
// 關閉流
if (null != fw) {
try {
fw.close();
} catch (IOException e) {
LOG.error("close file " + backFile.getAbsolutePath()
+ " IO error\n" + e.getMessage());
}
}
}
String log4j = WEB_INF_PATH + LOG4J_PROPERTIES_NAME;
backFile.renameTo(new File(log4j));
}


private void initData(FileWriter fw, String key, String value)
throws IOException {
fw.write(key + "=" + value + ENTER_CODE);
}


private String initPropsData(Properties props, String key,
String defaultValue) {
String value = props.getProperty(key);
value = (value == null || "".equals(value.trim())) ? defaultValue
: value;
return key + "=" + value + ENTER_CODE;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章