package com.pt.platform.core.common;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JYLoggerUtil
{
private static final Logger log = LoggerFactory.getLogger(JYLoggerUtil.class);
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static ThreadLocal
public static
{
Logger logger = LoggerFactory.getLogger(clazz);
logger.info(message);
}
public static
Logger logger = LoggerFactory.getLogger(clazz);
logger.info(message, t);
}
public static
Logger logger = LoggerFactory.getLogger(clazz);
logger.debug(message);
}
public static
{
Logger logger = LoggerFactory.getLogger(clazz);
logger.error(message);
}
public static
Logger logger = LoggerFactory.getLogger(clazz);
logger.error(message, ex);
}
public static
{
if (!log.isInfoEnabled()) return;
Map timeMap = (Map)threadMap.get();
if (timeMap == null) {
timeMap = new HashMap();
threadMap.set(timeMap);
}
String mapKey = cls.getName() + ":" + key;
Date curDate = new Date();
if (isStart) {
timeMap.put(mapKey, curDate);
} else {
Date lastDate = (Date)timeMap.get(mapKey);
if (lastDate != null) {
timeMap.remove(mapKey);
StringBuilder logInfo = new StringBuilder("=========");
logInfo.append(",(位置:").append(cls.getName());
logInfo.append(",内容:").append(key).append(")");
logInfo.append(",间隔:").append(curDate.getTime() - lastDate.getTime());
logInfo.append(",开始start:").append(sdf.format(lastDate));
logInfo.append(",结束end:").append(sdf.format(curDate)).append("=========");
log.info(logInfo.toString());
threadMap.remove();
}
}
}
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章