目录
日志
日记基础操作
编程期调试代码
运营期记录信息
记录日常运营重要信息(峰值流量,平均响应时长...)
记录应用报错信息(错误堆栈)
记录运维过程数据(扩容、报警..)
创建的springboot工程中
package com.comtroller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/logs")
public class LogController {
//创建记录日志的对象
private static final Logger log= LoggerFactory.getLogger(LogController.class);
@GetMapping
public String test(){
log.info("info..");
log.debug("debug..");
log.warn("warn..");
log.error("error..");
return "Logging ...";
}
运行结果
可以看出来debug级别的日志默认是关闭的
要开启debug只需要在配置文件中加入
//开启debug模式,输出调试信息,常用于检查系统运行状态
debug: true
一般这样设置
设置日志级别,root表示根节点,即整体应用日志级别
logging:
level:
root: debug