标签:log4j 代码 工具 .class stat ons pat factor log
工具代码
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.LogManager;
import org.apache.log4j.PatternLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LogUtil {
public static final Logger LOGGER = LoggerFactory.getLogger(LogUtil.class);
static {
org.apache.log4j.Logger logger = LogManager.getLogger(LOGGER.getName());
ConsoleAppender consoleAppender = new ConsoleAppender(new PatternLayout("%d [%t] %-5p [%c] - %m%n"));
logger.addAppender(consoleAppender);
}
}
使用
LogUtil.LOGGER.info("hello!");
标签:log4j 代码 工具 .class stat ons pat factor log
原文地址:https://www.cnblogs.com/liqipeng/p/9764173.html