日志级别:debug<info<warn<error
application.yml配置日志
代码语言:javascript复制logging:
file: target/app.log
level:
ROOT: WARN
cn.devmar: TRACE
代码语言:javascript复制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);
}
}
}
}