1.yml

说明:配置yml文件。debug、info、warn、error。

logging:
  level:
    root: debug

2.指定某个包

logging:
  level:
    root: info
#    设置某个包的日志级别
    com.forever.controller: debug

3.分组调试

logging:
  # 设置分组
  group:
    ebank: com.forever.controller
    iservice: com.alibaba
  level:
    root: info
#    设置某个包的日志级别
    com.forever.controller: debug

4.@Slf4j

说明:@Slf4j注解会在编译时自动生成一个名为log的日志对象。

@slf4j
@RestController
@RequestMapping("/books")
public class BookController
@GetMapping
public String getById(){
System.out.println("springboct is running...");
Log.debug("debug info...");
Log.info("infoinfo...");
Log.warn("warn info...");
Log.error("error info...");
return "springboot is running...";
}
}
11-05 23:41