?? recordlog.java
字號:
package client.chaowei.intraweb.bean.util;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
public final class RecordLog {
// 決定是否記錄日志的變量
private static boolean isRecord = true;
public RecordLog() {
}
public static void println(String log) {
if (isRecord) {
// 日志文件路徑
String logFile = "";
String s; // 流中介字符串
try {
String countFilePath = "/var/opt/SUNWappserver7/domains/domain1/server1/docroot/intrawebdoc/jnpcwebini/config.ini";
FileInputStream fis = new FileInputStream(countFilePath);
Properties prop = new Properties();
prop.load(fis);
// 服務器日志文件路徑
logFile = prop.getProperty("log_file");
// 創建字符串輸入流
BufferedReader br = new BufferedReader(new StringReader(log));
// 創建文件輸出流
PrintWriter pw = new PrintWriter(new FileWriter(logFile, true));
Date d = new Date();
// 轉換日期格式為:"yyyyMMddhhmmss"
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
String now = sdf.format(d);
// 輸出到文件
while ((s = br.readLine()) != null) {
pw.println(now + " : " + s);
pw.close();
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
//try語句結束
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -