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