From 28a0efc6ec16f3f82eb8e16e87269300d6744fd4 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 25 九月 2019 19:18:17 +0800 Subject: [PATCH] 金币版本拦截与频率拦截bug修改 --- fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java | 41 ++++++++++++++++++++++++++++------------- 1 files changed, 28 insertions(+), 13 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java b/fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java index 6ea645e..ae9d700 100644 --- a/fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java +++ b/fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java @@ -2,6 +2,7 @@ import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.util.ArrayList; @@ -92,41 +93,49 @@ loginLogger.info(obj); } - public static void errorDetailInfo(Throwable e) throws Exception { + public static void errorDetailInfo(Throwable e) { e.printStackTrace(); String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); String os = System.getProperty("os.name"); - String filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.txt", date); + String filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.log", date); if (os.toLowerCase().startsWith("win")) { - filePath = String.format("C:/logs/error_detail_%s.txt", date); + filePath = String.format("C:/logs/error_detail_%s.log", date); } else - filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.txt", date); + filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.log", date); - OutputStream out = new FileOutputStream(new File(filePath), true); + OutputStream out = null; + try { + out = new FileOutputStream(new File(filePath), true); PrintStream ps = new PrintStream(out); ps.print(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); ps.print("\n"); e.printStackTrace(ps); ps.flush(); ps.close(); + } catch (Exception ee) { + } finally { - out.close(); + try { + out.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } } } - public static void errorDetailInfo(Throwable e, String params, String url) throws Exception { + public static void errorDetailInfo(Throwable e, String params, String url) { e.printStackTrace(); String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); String os = System.getProperty("os.name"); - String filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.txt", date); + String filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.log", date); if (os.toLowerCase().startsWith("win")) { - filePath = String.format("C:/logs/error_detail_%s.txt", date); + filePath = String.format("C:/logs/error_detail_%s.log", date); } else - filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.txt", date); - - OutputStream out = new FileOutputStream(new File(filePath), true); + filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.log", date); + OutputStream out = null; try { + out = new FileOutputStream(new File(filePath), true); PrintStream ps = new PrintStream(out); ps.print(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); ps.print("\n"); @@ -137,8 +146,14 @@ e.printStackTrace(ps); ps.flush(); ps.close(); + } catch (Exception e1) { + } finally { - out.close(); + try { + out.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } } } -- Gitblit v1.8.0