工具代码
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!");
原文地址:https://www.cnblogs.com/liqipeng/p/9764173.html
时间: 2024-11-05 02:24:42