日志级别:debug<info<warn<error
application.yml配置日志
logging:
file: target/app.log
level:
ROOT: WARN
cn.devmar: TRACE
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class SampleClass{
private static final Log log = LogFactory.getLog(TvSeriesController.class);
public void print(String name){
if (log.isTraceEnabled()){
log.trace("getAll();被调用了");
}
try{
//do something
}catch(Exception e){
if(log.isErrorEnabled()){
log.error("出错了",e);
}
}
}
}