123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- //package com.example.xiaoshiweixinback.business.utils;
- //
- //import org.slf4j.Logger;
- //import org.slf4j.LoggerFactory;
- //import org.slf4j.MDC;
- //
- //import java.io.PrintWriter;
- //import java.io.StringWriter;
- //
- //
- ///**
- // * 日志工具类
- // *
- // * @author Peach
- // */
- //
- //public class LogHelper {
- //
- // private static Logger logger = null;
- //
- // //------------------------------------------系统日志记录-------------------------
- //
- // /**
- // * @param info
- // */
- //
- // public static void log(Object... info) {
- // logger = LoggerFactory.getLogger("");
- // logger.info("info={}", info);
- // }
- //
- // public static void log(Throwable e, Object... info) {
- // logger = LoggerFactory.getLogger("");
- // logger.info("exception={} info={}", throwable2String(e), info);
- // }
- //
- //
- // /**
- // * @param clazz
- // * @param info
- // */
- //
- // public static void log(Class clazz, String info) {
- // logger = LoggerFactory.getLogger(clazz);
- // logger.info(info);
- // }
- //
- //
- // /**
- // * @param clazz
- // * @param e
- // */
- //
- // public static void log(Class clazz, Throwable e) {
- // log(clazz, throwable2String(e));
- // }
- //
- // /**
- // * @param name
- // * @param info
- // */
- //
- // @Deprecated
- // public static void log(String name, String info) {
- // logger = LoggerFactory.getLogger(name);
- // logger.info(name + "-" + info);
- // }
- //
- //
- // /**
- // * @param name
- // * @param e
- // */
- //
- // @Deprecated
- // public static void log(String name, Throwable e) {
- // log(name, throwable2String(e));
- // }
- //
- //
- // /**
- // * @param name
- // * @param info
- // * @param e
- // */
- // @Deprecated
- // public static void log(String name, String info, Throwable e) {
- // log(name, info + "-" + throwable2String(e));
- // }
- //
- //
- // /**
- // * @param clazz
- // * @param info
- // * @param e
- // */
- // public static void log(Class clazz, String info, Throwable e) {
- // log(clazz, info + "-" + throwable2String(e));
- // }
- //
- //
- // /**
- // * 将异常信息转为string
- // *
- // * @param e
- // * @return
- // */
- //
- // private static String throwable2String(Throwable e) {
- // if (checkBaseBusinessException(e)) {
- // BaseBusinessException bbe = (BaseBusinessException) e;
- // return "----->" + bbe.getErrorMessage() + (bbe.getExtraMessage() == null ? "" : bbe.getExtraMessage());
- // }
- // PrintWriter pw = null;
- // StringWriter sw = null;
- // try {
- // sw = new StringWriter();
- // pw = new PrintWriter(sw);
- // e.printStackTrace(pw);
- // pw.flush();
- // sw.flush();
- // } catch (Exception e1) {
- // logger.info(e.getMessage());
- // } finally {
- // if (sw != null) {
- // try {
- // sw.close();
- // } catch (Exception e2) {
- // e2.printStackTrace();
- // return "";
- // }
- // } else {
- // return "";
- // }
- // if (pw != null) {
- // pw.close();
- // }
- // return sw.toString();
- // }
- //
- // }
- //
- //
- // /**
- // * @param @param e
- // * @param @return 参数
- // * @return boolean 返回类型
- // * @throws
- // * @Title: checkBaseBusinessException
- // * @Description: 判断异常是否为系统异常
- // * @author Orange
- // * @date 2019年1月23日
- // */
- //
- // private static boolean checkBaseBusinessException(Throwable e) {
- // return BaseBusinessException.class.isInstance(e);
- // }
- //
- //
- // //------------------------------------------多业务日志记录-------------------------
- // /**
- // * @param @param e
- // * @param @param info 参数
- // * @return void 返回类型
- // * @throws
- // * @Title: warnLog
- // * @Description: 警告日志
- // * @author Orange
- // * @date 2019年1月26日
- // */
- // public static void warnLog(Throwable e, Object... info) {
- // //系统级别日志不打印
- // if (checkBaseBusinessException(e)) {
- // log(e, info);
- // } else {
- // Logger logger = LoggerFactory.getLogger("error_log");
- // logger.warn("[System Exception] exception={} ,info={}", throwable2String(e), info);
- // }
- // }
- //}
|