From 3ce9e928e082ff8abf697dba560cbfbb412e89f8 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 11 十一月 2019 15:45:02 +0800
Subject: [PATCH] 商城后台编辑

---
 fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java |   62 +++++++++++++++++++++++-------
 1 files changed, 47 insertions(+), 15 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..54acf41 100644
--- a/fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java
+++ b/fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java
@@ -2,14 +2,13 @@
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
 
 import org.apache.log4j.Logger;
 
@@ -42,6 +41,10 @@
 	private static Logger requestLogger = Logger.getLogger("requestLog");
 
 	private static Logger requestTimeLogger = Logger.getLogger("requestTimeLog");
+
+	private static Logger jobLogger = Logger.getLogger("jobLog");
+
+	private static Logger mqLogger = Logger.getLogger("mqLog");
 
 	public static void userInfo(Object obj) {
 		userLogger.info(obj);
@@ -83,6 +86,21 @@
 		shareGoodsLogger.info(obj);
 	}
 
+	public static void job(Object obj) {
+		jobLogger.info(obj);
+	}
+
+	public static void mqError(String errorMsg, String topic, String tag, Object data) {
+		String error = errorMsg + "\ntopic:" + topic + "\ntag:" + tag + "\nbody:" + data;
+		mqLogger.error(error);
+	}
+	
+	public static void mqInfo(String extraInfo,String msgId, String topic, String tag, Object data) {
+		String info = extraInfo+"\nmsgId"+msgId + "\ntopic:" + topic + "\ntag:" + tag + "\nbody:" + data;
+		mqLogger.info(info);
+	}
+
+
 	/**
 	 * 鐧诲綍淇℃伅
 	 * 
@@ -92,41 +110,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 +163,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