copy from src/xitongshezhi/Charulog.java
copy to src/dialog/Errlog.java
| Îļþ´Ó src/xitongshezhi/Charulog.java ¸´ÖÆ |
| | |
| | | package xitongshezhi; |
| | | package dialog; |
| | | |
| | | import java.io.*; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | |
| | | public class Charulog { |
| | | private static final String LOG_FILE = "log.properties"; |
| | | public class Errlog { |
| | | private static final String LOG_FILE = "err.properties"; |
| | | private static final int MAX_RECORDS = 500; |
| | | private static final ReentrantLock lock = new ReentrantLock(); |
| | | private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | File file = new File(LOG_FILE); |
| | | |
| | | if (file.exists()) { |
| | | try (FileInputStream fis = new FileInputStream(file)) { |
| | | props.load(fis); |
| | | try (FileInputStream fis = new FileInputStream(file); |
| | | InputStreamReader isr = new InputStreamReader(fis, "UTF-8")) { |
| | | props.load(isr); |
| | | } catch (IOException e) { |
| | | System.err.println("è¯»åæ¥å¿æä»¶å¤±è´¥: " + e.getMessage()); |
| | | } |
| | |
| | | * åå
¥æ¥å¿æä»¶ |
| | | */ |
| | | private static void writeLogFile(Properties props) { |
| | | try (FileOutputStream fos = new FileOutputStream(LOG_FILE)) { |
| | | try (FileOutputStream fos = new FileOutputStream(LOG_FILE); |
| | | OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8")) { |
| | | // æ·»å æä»¶å¤´æ³¨é |
| | | props.store(fos, "æä½æ¥å¿è®°å½ - æåæ´æ°: " + new Date()); |
| | | props.store(osw, "æä½æ¥å¿è®°å½ - æåæ´æ°: " + new Date()); |
| | | } catch (IOException e) { |
| | | System.err.println("åå
¥æ¥å¿æä»¶å¤±è´¥: " + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åå½åæ¥å¿è®°å½æ°éï¼ç¨äºæµè¯ï¼ |
| | | */ |