java 日志记录异常

import org.apache.commons.lang.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


	private Logger logger = LoggerFactory.getLogger(getClass());
	public void getTest(){
		try {
			int a=1/0;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("111"+e.getMessage());
			logger.error("222{}",e.getMessage());
			logger.error("333",e); // 推荐
			logger.error(ExceptionUtils.getMessage(e));
			logger.error(ExceptionUtils.getStackTrace(e));//推荐
		}
	}

你可能感兴趣的:(JAVA,Exception)