传统做法
private final Logger logger = LoggerFactory.getLogger(LoggerTest.class);
/**
* 传统方式实现日志
*/
@Test
public void test1(){
logger.debug("debug");//默认日志级别为info
logger.info("info");
logger.error("error");
logger.warn("warn");
}
方便做法
若嫌太麻烦可以使用@sel4j
@Slf4j //类上添加此注解
@Test
public void test2(){
log.debug("debug");//默认日志级别为info
log.info("info");
log.error("error");
log.warn("warn");
}