package com.atheima.controller.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BaseLog {
private Class clazz = null;
public static Logger log;
public BaseLog(){
clazz = this.getClass();
log = LoggerFactory.getLogger(clazz);
}
//第二中實現方法
/* private final Logger log;
public BaseLog() {
log = LoggerFactory.getLogger(this.getClass());
}
public void info(String message) {
log.info(message);
}
public void debug(String message){
log.debug(message);
}*/
}
某類繼承該工具類,就可以直接使用log了
- 或者使用更省事的方法,引入lombok,直接在某類上使用註解@Slf4j