You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.6 KiB

package ${basePackage}.frame.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* LogUtil -
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class LogUtil {
//定义一个全局的记录器通过LoggerFactory获取
private final static Logger logger = LoggerFactory.getLogger(LogUtil.class);
/**
* info
* @param context
*/
public static void i(String context){
logger.info(context);
}
/**
* debug
* @param context
*/
public static void d(String context){
logger.debug(context);
}
/**
* warn
* @param context
*/
public static void w(String context){
logger.warn(context);
}
/**
* error
* @param context
*/
public static void e(String context){
logger.error(context);
}
/**
*
*/
public static void dumpException(Throwable e){
StringBuffer msg = new StringBuffer("null");
if (e != null) {
msg = new StringBuffer("");
String message = e.toString();
int length = e.getStackTrace().length;
if (length > 0) {
msg.append(message).append("\n");
for (int i = 0; i < length; i++) {
msg.append("\t").append(e.getStackTrace()[i]).append("\n");
}
} else {
msg.append(message);
}
}
logger.error(msg.toString());
}
}

Powered by TurnKey Linux.