📄 log.java
字号:
package com.sxit.wap.common;import java.io.*;public class Log { public static void write(String url, String s) { try { FileOutputStream fos = new FileOutputStream("error.log", true); PrintWriter pw = new PrintWriter(fos); s = DateUtil.getYYYYMMDDHHMISS() + ">>>>>>>>" + url + "发生如下错误:" + s; pw.println(s); pw.flush(); fos.flush(); } catch(Exception ex) { ex.printStackTrace(); } } public static void write(String url, Exception e) { try { FileOutputStream fos = new FileOutputStream("error.log", true); PrintWriter pw = new PrintWriter(fos); pw.println(DateUtil.getYYYYMMDDHHMISS() + ">>>>>>>>" + url + "发生如下错误:"); pw.println(e); pw.flush(); fos.flush(); } catch(Exception ex) { ex.printStackTrace(); } } public static void write(String url, String s, Exception e) { try { FileOutputStream fos = new FileOutputStream("error.log", true); PrintWriter pw = new PrintWriter(fos); s = DateUtil.getYYYYMMDDHHMISS() + ">>>>>>>>" + url + "发生如下错误:" + s; pw.println(s); pw.println(e); pw.flush(); fos.flush(); } catch(Exception ex) { ex.printStackTrace(); } } public static void main(String[] args) throws IOException { try { int i = 1/0; }catch(Exception e) { } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -