代码如下:
try{ ****** } catch (Exception ex) { try { File file = new File("e:/log.txt"); PrintWriter writer = null; FileWriter fileWrite = new FileWriter(String.valueOf(file), true); writer = new PrintWriter(fileWrite); writer.append(System.getProperty("line.separator") + new SimpleDateFormat("yyyy-MM-dd:HH:mm:ss").format(new Date())); writer.append(System.getProperty("line.separator")); writer.append("*************************" + ex.toString() + "*************************"); writer.append(System.getProperty("line.separator")); ex.printStackTrace(writer); writer.flush(); writer.close(); } catch (IOException e) { e.printStackTrace(); } } |
时间: 2024-10-13 16:10:14